public SignatureContext(ISignable signable) { this.Signable = signable; this.ScriptHashes = signable.GetScriptHashesForVerifying(); this.redeemScripts = new byte[ScriptHashes.Length][]; this.signatures = new Dictionary <ECPoint, byte[]> [ScriptHashes.Length]; }
internal static bool VerifySignature(this ISignable signable) { UInt160[] hashes; try { hashes = signable.GetScriptHashesForVerifying(); } catch (InvalidOperationException) { return(false); } if (hashes.Length != signable.Scripts.Length) { return(false); } for (int i = 0; i < hashes.Length; i++) { if (hashes[i] != signable.Scripts[i].RedeemScript.ToScriptHash()) { return(false); } ScriptEngine engine = new ScriptEngine(signable.Scripts[i], signable, InterfaceEngine.Default); if (!engine.Execute()) { return(false); } } return(true); }
public SignatureContext(ISignable signable) { this.Signable = signable; this.ScriptHashes = signable.GetScriptHashesForVerifying(); this.redeemScripts = new byte[ScriptHashes.Length][]; this.signatures = new Dictionary<ECPoint, byte[]>[ScriptHashes.Length]; }
/// <summary> /// 对指定的数据构造签名上下文 /// </summary> /// <param name="signable">要签名的数据</param> public SignatureContext(ISignable signable) { this.Signable = signable; this.ScriptHashes = signable.GetScriptHashesForVerifying(); this.redeemScripts = new byte[ScriptHashes.Length][]; this.parameters = new byte[ScriptHashes.Length][][]; this.temp = new JObject[ScriptHashes.Length]; }
internal static bool VerifySignature(this ISignable signable) { UInt160[] hashes; try { hashes = signable.GetScriptHashesForVerifying(); } catch (InvalidOperationException) { return(false); } if (hashes.Length != signable.Scripts.Length) { return(false); } for (int i = 0; i < hashes.Length; i++) { byte[] redeem_script = signable.Scripts[i].RedeemScript; if (redeem_script.Length == 0) { using (ScriptBuilder sb = new ScriptBuilder()) { sb.EmitAppCall(hashes[i].ToArray()); redeem_script = sb.ToArray(); } } else { if (hashes[i] != redeem_script.ToScriptHash()) { return(false); } } ExecutionEngine engine = new ExecutionEngine(signable, ECDsaCrypto.Default, 1200, Blockchain.Default, InterfaceEngine.Default); engine.LoadScript(redeem_script, false); engine.LoadScript(signable.Scripts[i].StackScript, true); engine.Execute(); if (engine.State != VMState.HALT) { return(false); } if (engine.EvaluationStack.Count != 1 || !engine.EvaluationStack.Pop().GetBoolean()) { return(false); } } return(true); }
internal static bool VerifySignature(this ISignable signable) { UInt160[] hashes; try { hashes = signable.GetScriptHashesForVerifying(); } catch (InvalidOperationException) { return(false); } if (hashes.Length != signable.Scripts.Length) { return(false); } for (int i = 0; i < hashes.Length; i++) { if (hashes[i] != signable.Scripts[i].RedeemScript.ToScriptHash()) { return(false); } ScriptEngine engine = new ScriptEngine(signable, ECDsaCrypto.Default, Blockchain.Default, InterfaceEngine.Default); if (!engine.ExecuteScript(signable.Scripts[i].StackScript, true)) { return(false); } if (!engine.ExecuteScript(signable.Scripts[i].RedeemScript, false)) { return(false); } if (engine.Stack.Count != 1 || !engine.Stack.Pop()) { return(false); } } return(true); }
public SignatureContext(ISignable signable) { this.Signable = signable; this.ScriptHashes = signable.GetScriptHashesForVerifying(); this.signatures = new MultiSigContext[ScriptHashes.Length]; }