Search in sources :

Example 1 with ECKey

use of org.bitcoinj.core.ECKey in project bitsquare by bitsquare.

the class ArbitratorManager method verifySignature.

private boolean verifySignature(PublicKey storageSignaturePubKey, byte[] registrationPubKey, String signature) {
    String keyToSignAsHex = Utils.HEX.encode(storageSignaturePubKey.getEncoded());
    try {
        ECKey key = ECKey.fromPublicOnly(registrationPubKey);
        key.verifyMessage(keyToSignAsHex, signature);
        return true;
    } catch (SignatureException e) {
        log.warn("verifySignature failed");
        return false;
    }
}
Also used : ECKey(org.bitcoinj.core.ECKey) SignatureException(java.security.SignatureException)

Example 2 with ECKey

use of org.bitcoinj.core.ECKey in project bitsquare by bitsquare.

the class ArbitratorRegistrationViewModel method setPrivKeyAndCheckPubKey.

boolean setPrivKeyAndCheckPubKey(String privKeyString) {
    ECKey _registrationKey = arbitratorManager.getRegistrationKey(privKeyString);
    if (_registrationKey != null) {
        String _registrationPubKeyAsHex = Utils.HEX.encode(_registrationKey.getPubKey());
        boolean isKeyValid = arbitratorManager.isPublicKeyInList(_registrationPubKeyAsHex);
        if (isKeyValid) {
            registrationKey = _registrationKey;
            registrationPubKeyAsHex.set(_registrationPubKeyAsHex);
        }
        updateDisableStates();
        return isKeyValid;
    } else {
        updateDisableStates();
        return false;
    }
}
Also used : ECKey(org.bitcoinj.core.ECKey)

Aggregations

ECKey (org.bitcoinj.core.ECKey)2 SignatureException (java.security.SignatureException)1