/// <summary> /// Returns HoardID that signed this transaction /// </summary> /// <param name="signatureStr"></param> /// <param name="rlpEncodedTransaction"></param> /// <returns>Signer of this transaction</returns> public static HoardID RecoverHoardIdFromTransaction(string signatureStr, byte[] rlpEncodedTransaction) { if (string.IsNullOrEmpty(signatureStr)) { return(null); } var signature = EthECDSASignatureFactory.ExtractECDSASignature(signatureStr); var rawHash = new Nethereum.Util.Sha3Keccack().CalculateHash(rlpEncodedTransaction); return(new HoardID(EthECKey.RecoverFromSignature(signature, rawHash).GetPublicAddress())); }
public static bool verify(string dataStr, string signStr) { try { var sign = EthECDSASignatureFactory.ExtractECDSASignature(signStr); var dataHash = new Sha3Keccack().CalculateHash(Encoding.UTF8.GetBytes(dataStr)); var pubKey = EthECKey.RecoverFromSignature(sign, dataHash); return(pubKey.Verify(dataHash, sign)); }catch { return(false); } }
public string Recover(string message, byte[] signature, bool preFixed) { var bytes = Encoding.ASCII.GetBytes(message); if (!preFixed) { bytes = this.HashMessage(bytes); } var ecdaSignature = EthECDSASignatureFactory.ExtractECDSASignature(signature.ToHex()); return(Bech32.Encode("io", Hash.Hash160B(EthECKey.RecoverFromSignature(ecdaSignature, bytes).GetPubKey().Slice(1)))); }