use of tech.pegasys.signers.secp256k1.filebased.CredentialSigner 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.filebased.CredentialSigner in project web3signer by ConsenSys.
the class FcSecpArtifactSignerTest method setup.
@BeforeEach
public void setup() {
final Bytes fcPrivateKey = Bytes.fromBase64String(FC_SECP_PRIVATE_KEY);
final Credentials credentials = Credentials.create(fcPrivateKey.toHexString());
fcSecpArtifactSigner = new FcSecpArtifactSigner(new CredentialSigner(credentials, false), FilecoinNetwork.TESTNET);
}
use of tech.pegasys.signers.secp256k1.filebased.CredentialSigner in project web3signer by ConsenSys.
the class EthSecpArtifactSignerTest method publicKeyIsReturnedAsIdentifier.
@Test
void publicKeyIsReturnedAsIdentifier() {
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));
assertThat(ethSecpArtifactSigner.getIdentifier()).isEqualTo("0x" + PUBLIC_KEY);
}
use of tech.pegasys.signers.secp256k1.filebased.CredentialSigner in project signers by ConsenSys.
the class HashicorpSignerFactory method create.
public Signer create(final HashicorpKeyConfig keyConfig) {
try {
final HashicorpConnectionFactory connectionFactory = new HashicorpConnectionFactory(vertx);
final HashicorpConnection connection = connectionFactory.create(keyConfig.getConnectionParams());
final String secret = connection.fetchKey(keyConfig.getKeyDefinition());
final Credentials credentials = Credentials.create(secret);
return new CredentialSigner(credentials);
} catch (final HashicorpException e) {
throw new SignerInitializationException("Failed to extract secret from Hashicorp vault.", e);
}
}
use of tech.pegasys.signers.secp256k1.filebased.CredentialSigner in project web3signer by ConsenSys.
the class EthSecpArtifactSignerTest method publicKeyIsReturnedAsIdentifier.
@Test
void publicKeyIsReturnedAsIdentifier() {
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));
assertThat(ethSecpArtifactSigner.getIdentifier()).isEqualTo("0x" + PUBLIC_KEY);
}
Aggregations