use of org.tron.common.crypto.ECKey.ECDSASignature in project java-tron by tronprotocol.
the class BlockCapsule method sign.
public void sign(byte[] privateKey) {
// TODO private_key == null
ECKey ecKey = ECKey.fromPrivate(privateKey);
ECDSASignature signature = ecKey.sign(getRawHash().getBytes());
ByteString sig = ByteString.copyFrom(signature.toBase64().getBytes());
BlockHeader blockHeader = this.block.getBlockHeader().toBuilder().setWitnessSignature(sig).build();
this.block = this.block.toBuilder().setBlockHeader(blockHeader).build();
}
use of org.tron.common.crypto.ECKey.ECDSASignature in project java-tron by tronprotocol.
the class TransactionCapsule method getBase64FromByteString.
public static String getBase64FromByteString(ByteString sign) {
byte[] r = sign.substring(0, 32).toByteArray();
byte[] s = sign.substring(32, 64).toByteArray();
byte v = sign.byteAt(64);
if (v < 27) {
// revId -> v
v += 27;
}
ECDSASignature signature = ECDSASignature.fromComponents(r, s, v);
return signature.toBase64();
}
use of org.tron.common.crypto.ECKey.ECDSASignature in project java-tron by tronprotocol.
the class TransactionCapsule method sign.
public void sign(byte[] privateKey) {
ECKey ecKey = ECKey.fromPrivate(privateKey);
ECDSASignature signature = ecKey.sign(getRawHash().getBytes());
ByteString sig = ByteString.copyFrom(signature.toBase64().getBytes());
this.transaction = this.transaction.toBuilder().addSignature(sig).build();
}
Aggregations