void Init() { SignatureMap.Each(modulePair => { var moduleName = modulePair.Key; var moduleSigDict = modulePair.Value; var module = Native.GetModuleBaseByName(moduleName); if (module == null) { return; } if (!SignatureResult.ContainsKey(moduleName)) { SignatureResult.Add(moduleName, new Dictionary <string, IntPtr>()); } moduleSigDict.Each(sigPair => { if (sigPair.Value == null) { return; } SignatureResult[moduleName][sigPair.Key] = sigPair.Value.Item1.SignatureScan(module.Item1, module.Item2) + sigPair.Value.Item2; }); }); }
internal SignedTransaction GetSignedTransaction(int prefixTrimLimit) { var count = _signatures.Count; if (count == 0) { throw new InvalidOperationException("A transaction or query requires at least one signature, sometimes more. None were found, did you forget to assign a Signatory to the context, transaction or query?"); } var signatures = new SignatureMap(); if (count == 1 && prefixTrimLimit < 1) { signatures.SigPair.Add(_signatures.Values.First()); } else { var list = _signatures.ToArray(); var keys = new byte[count][]; for (var length = Math.Max(1, prefixTrimLimit); true; length++) { var unique = true; for (var i = 0; unique && i < count; i++) { var key = keys[i] = list[i].Key.Memory.Slice(0, Math.Min(list[i].Key.Length, length)).ToArray(); for (var j = 0; j < i; j++) { if (Enumerable.SequenceEqual(key, keys[j])) { unique = false; break; } } } if (unique) { break; } } for (var i = 0; i < count; i++) { var sig = list[i].Value; sig.PubKeyPrefix = ByteString.CopyFrom(keys[i]); signatures.SigPair.Add(sig); } } return(new SignedTransaction { BodyBytes = ByteString.CopyFrom(_txBytes.Span), SigMap = signatures }); }
internal SignatureMap?TryGenerateMapFromCollectedSignatures(int prefixTrimLimit) { var count = _signatures.Count; if (count == 0) { return(null); } var map = new SignatureMap(); if (count == 1 && prefixTrimLimit < 1) { map.SigPair.Add(_signatures.Values.First()); } else { var list = _signatures.ToArray(); var keys = new byte[count][]; for (var length = Math.Max(1, prefixTrimLimit); true; length++) { var unique = true; for (var i = 0; unique && i < count; i++) { var key = keys[i] = list[i].Key.Memory.Slice(0, Math.Min(list[i].Key.Length, length)).ToArray(); for (var j = 0; j < i; j++) { if (Enumerable.SequenceEqual(key, keys[j])) { unique = false; break; } } } if (unique) { break; } } for (var i = 0; i < count; i++) { var sig = list[i].Value; sig.PubKeyPrefix = ByteString.CopyFrom(keys[i]); map.SigPair.Add(sig); } } return(map.SigPair.Count > 0 ? map : null); }
internal Transaction GetSignedTransaction() { if (_signatures.Count == 0) { throw new InvalidOperationException("A transaction or query requires at least one signature, sometimes more. None were found, did you forget to assign a Signatory to the context, transaction or query?"); } var signatures = new SignatureMap(); foreach (var signature in _signatures.Values) { signatures.SigPair.Add(signature); } return(new Transaction { BodyBytes = ByteString.CopyFrom(_txBytes.Span), SigMap = signatures }); }