use of tech.pegasys.signers.secp256k1.api.Signature in project web3signer by ConsenSys.
the class EthSecpArtifactSignerTest method signsData.
@Test
void signsData() {
final ECKeyPair ecKeyPair = new ECKeyPair(Numeric.toBigInt(PRIVATE_KEY), Numeric.toBigInt(PUBLIC_KEY));
final Credentials credentials = Credentials.create(ecKeyPair);
final EthSecpArtifactSigner ethSecpArtifactSigner = new EthSecpArtifactSigner(new CredentialSigner(credentials));
final Bytes message = Bytes.wrap("Hello, world!".getBytes(UTF_8));
final SecpArtifactSignature signature = ethSecpArtifactSigner.sign(message);
final SignatureData expectedSignature = Sign.signMessage(message.toArrayUnsafe(), ecKeyPair);
final Signature signatureData = signature.getSignatureData();
assertThat(signatureData.getR()).isEqualTo(Numeric.toBigInt(expectedSignature.getR()));
assertThat(signatureData.getS()).isEqualTo(Numeric.toBigInt(expectedSignature.getS()));
assertThat(signatureData.getV()).isEqualTo(Numeric.toBigInt(expectedSignature.getV()));
}
use of tech.pegasys.signers.secp256k1.api.Signature in project web3signer by ConsenSys.
the class FilecoinVerifyTest method createSecpArtifactSignature.
private SecpArtifactSignature createSecpArtifactSignature(final Bytes signature) {
final Bytes r = signature.slice(0, 32);
final Bytes s = signature.slice(32, 32);
final Bytes v = signature.slice(64);
return new SecpArtifactSignature(new Signature(Numeric.toBigInt(v.toArrayUnsafe()), Numeric.toBigInt(r.toArrayUnsafe()), Numeric.toBigInt(s.toArrayUnsafe())));
}
use of tech.pegasys.signers.secp256k1.api.Signature in project web3signer by ConsenSys.
the class SecpArtifactSignature method fromBytes.
public static SecpArtifactSignature fromBytes(final Bytes signature) {
final Bytes r = signature.slice(0, 32);
final Bytes s = signature.slice(32, 32);
final Bytes v = signature.slice(64);
return new SecpArtifactSignature(new Signature(Numeric.toBigInt(v.toArrayUnsafe()), Numeric.toBigInt(r.toArrayUnsafe()), Numeric.toBigInt(s.toArrayUnsafe())));
}
Aggregations