generateSignature(exchange.getExchangeSpecification().getSecretKey(), hash_data); byte v = sig.getV(); byte[] r = sig.getR(); byte[] s = sig.getS(); orderReq =
result.add(RlpString.create(Bytes.trimLeadingZeroes(signatureData.getR()))); result.add(RlpString.create(Bytes.trimLeadingZeroes(signatureData.getS())));
static BigInteger signedMessageHashToKey( byte[] messageHash, SignatureData signatureData) throws SignatureException { byte[] r = signatureData.getR(); byte[] s = signatureData.getS(); verifyPrecondition(r != null && r.length == 32, "r must be 32 bytes"); verifyPrecondition(s != null && s.length == 32, "s must be 32 bytes"); int header = signatureData.getV() & 0xFF; // The header byte: 0x1B = first key with even y, 0x1C = first key with odd y, // 0x1D = second key with even y, 0x1E = second key with odd y if (header < 27 || header > 34) { throw new SignatureException("Header byte out of range: " + header); } ECDSASignature sig = new ECDSASignature( new BigInteger(1, signatureData.getR()), new BigInteger(1, signatureData.getS())); int recId = header - 27; BigInteger key = recoverFromSignature(recId, sig, messageHash); if (key == null) { throw new SignatureException("Could not recover public key from signature"); } return key; }
result.add(RlpString.create(Bytes.trimLeadingZeroes(signatureData.getR()))); result.add(RlpString.create(Bytes.trimLeadingZeroes(signatureData.getS())));
static BigInteger signedMessageHashToKey( byte[] messageHash, SignatureData signatureData) throws SignatureException { byte[] r = signatureData.getR(); byte[] s = signatureData.getS(); verifyPrecondition(r != null && r.length == 32, "r must be 32 bytes"); verifyPrecondition(s != null && s.length == 32, "s must be 32 bytes"); int header = signatureData.getV() & 0xFF; // The header byte: 0x1B = first key with even y, 0x1C = first key with odd y, // 0x1D = second key with even y, 0x1E = second key with odd y if (header < 27 || header > 34) { throw new SignatureException("Header byte out of range: " + header); } ECDSASignature sig = new ECDSASignature( new BigInteger(1, signatureData.getR()), new BigInteger(1, signatureData.getS())); int recId = header - 27; BigInteger key = recoverFromSignature(recId, sig, messageHash); if (key == null) { throw new SignatureException("Could not recover public key from signature"); } return key; }
public String getFrom() throws SignatureException { Integer chainId = getChainId(); byte[] encodedTransaction; if (null == chainId) { encodedTransaction = TransactionEncoder.encode(this); } else { encodedTransaction = TransactionEncoder.encode(this, chainId.byteValue()); } byte v = signatureData.getV(); byte[] r = signatureData.getR(); byte[] s = signatureData.getS(); Sign.SignatureData signatureDataV = new Sign.SignatureData(getRealV(v), r, s); BigInteger key = Sign.signedMessageToKey(encodedTransaction, signatureDataV); return "0x" + Keys.getAddress(key); }
public static Sign.SignatureData createEip155SignatureData( Sign.SignatureData signatureData, byte chainId) { byte v = (byte) (signatureData.getV() + (chainId << 1) + 8); return new Sign.SignatureData( v, signatureData.getR(), signatureData.getS()); }
BigInteger publicKey = Sign.recoverFromSignature( (byte) i, new ECDSASignature(new BigInteger(1, sd.getR()), new BigInteger(1, sd.getS())), msgHash);
public String getFrom() throws SignatureException { Integer chainId = getChainId(); byte[] encodedTransaction; if (null == chainId) { encodedTransaction = TransactionEncoder.encode(this); } else { encodedTransaction = TransactionEncoder.encode(this, chainId.byteValue()); } byte v = signatureData.getV(); byte[] r = signatureData.getR(); byte[] s = signatureData.getS(); Sign.SignatureData signatureDataV = new Sign.SignatureData(getRealV(v), r, s); BigInteger key = Sign.signedMessageToKey(encodedTransaction, signatureDataV); return "0x" + Keys.getAddress(key); }
public static Sign.SignatureData createEip155SignatureData( Sign.SignatureData signatureData, byte chainId) { byte v = (byte) (signatureData.getV() + (chainId << 1) + 8); return new Sign.SignatureData( v, signatureData.getR(), signatureData.getS()); }