@Test public void testCreateAuthInitiate() throws Exception { AuthInitiateMessage message = initiator.createAuthInitiate(new byte[32], myKey); int expectedLength = 65+32+64+32+1; byte[] buffer = message.encode(); assertEquals(expectedLength, buffer.length); }
public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = key.keyAgreement(remotePublicKey); token = ByteUtil.bigIntegerToBytes(secretScalar, NONCE_SIZE); } else { isToken = true; } byte[] nonce = initiatorNonce; byte[] signed = xor(token, nonce); message.signature = ephemeralKey.sign(signed); message.isTokenUsed = isToken; message.ephemeralPublicHash = sha3(ephemeralKey.getPubKey(), 1, 64); message.publicKey = key.getPubKeyPoint(); message.nonce = initiatorNonce; return message; }
EncryptionHandshake { public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = key.keyAgreement(remotePublicKey); token = ByteUtil.bigIntegerToBytes(secretScalar, NONCE_SIZE); } else { isToken = true; } byte[] nonce = initiatorNonce; byte[] signed = xor(token, nonce); message.signature = ephemeralKey.sign(signed); message.isTokenUsed = isToken; message.ephemeralPublicHash = sha3(ephemeralKey.getPubKey(), 1, 64); message.publicKey = key.getPubKeyPoint(); message.nonce = initiatorNonce; return message; } }
EncryptionHandshake { public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = key.keyAgreement(remotePublicKey); token = ByteUtil.bigIntegerToBytes(secretScalar, NONCE_SIZE); } else { isToken = true; } byte[] nonce = initiatorNonce; byte[] signed = xor(token, nonce); message.signature = ephemeralKey.sign(signed); message.isTokenUsed = isToken; message.ephemeralPublicHash = sha3(ephemeralKey.getPubKey(), 1, 64); message.publicKey = key.getPubKeyPoint(); message.nonce = initiatorNonce; return message; } EncryptionHandshake(ECPoint remotePublicKey);   EncryptionHandshake(ECPoint remotePublicKey, ECKey ephemeralKey, byte[] initiatorNonce, byte[] responderNonce, boolean isInitiator);  EncryptionHandshake(); }
EncryptionHandshake { public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = key.keyAgreement(remotePublicKey); token = ByteUtil.bigIntegerToBytes(secretScalar, NONCE_SIZE); } else { isToken = true; } byte[] nonce = initiatorNonce; byte[] signed = xor(token, nonce); message.signature = ephemeralKey.sign(signed); message.isTokenUsed = isToken; message.ephemeralPublicHash = sha3(ephemeralKey.getPubKey(), 1, 64); message.publicKey = key.getPubKeyPoint(); message.nonce = initiatorNonce; return message; } EncryptionHandshake(ECPoint remotePublicKey);   EncryptionHandshake(ECPoint remotePublicKey, ECKey ephemeralKey, byte[] initiatorNonce, byte[] responderNonce, boolean isInitiator);  EncryptionHandshake(); AuthInitiateMessageV4 createAuthInitiateV4(ECKey key); byte[] encryptAuthInitiateV4(AuthInitiateMessageV4 message); AuthInitiateMessageV4 decryptAuthInitiateV4(byte[] in, ECKey myKey); byte[] encryptAuthResponseV4(AuthResponseMessageV4 message); AuthResponseMessageV4 decryptAuthResponseV4(byte[] in, ECKey myKey); AuthResponseMessageV4 handleAuthResponseV4(ECKey myKey, byte[] initiatePacket, byte[] responsePacket); AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key); byte[] encryptAuthMessage(AuthInitiateMessage message); byte[] encryptAuthResponse(AuthResponseMessage message); AuthResponseMessage decryptAuthResponse(byte[] ciphertext, ECKey myKey); AuthInitiateMessage decryptAuthInitiate(byte[] ciphertext, ECKey myKey); AuthResponseMessage handleAuthResponse(ECKey myKey, byte[] initiatePacket, byte[] responsePacket); byte[] handleAuthInitiate(byte[] initiatePacket, ECKey key); static byte recIdFromSignatureV(int v); Secrets getSecrets(); ECPoint getRemotePublicKey(); boolean isInitiator(); }
EncryptionHandshake { public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = key.keyAgreement(remotePublicKey); token = ByteUtil.bigIntegerToBytes(secretScalar, NONCE_SIZE); } else { isToken = true; } byte[] nonce = initiatorNonce; byte[] signed = xor(token, nonce); message.signature = ephemeralKey.sign(signed); message.isTokenUsed = isToken; message.ephemeralPublicHash = sha3(ephemeralKey.getPubKey(), 1, 64); message.publicKey = key.getPubKeyPoint(); message.nonce = initiatorNonce; return message; } EncryptionHandshake(ECPoint remotePublicKey);   EncryptionHandshake(ECPoint remotePublicKey, ECKey ephemeralKey, byte[] initiatorNonce, byte[] responderNonce, boolean isInitiator);  EncryptionHandshake(); AuthInitiateMessageV4 createAuthInitiateV4(ECKey key); byte[] encryptAuthInitiateV4(AuthInitiateMessageV4 message); AuthInitiateMessageV4 decryptAuthInitiateV4(byte[] in, ECKey myKey); byte[] encryptAuthResponseV4(AuthResponseMessageV4 message); AuthResponseMessageV4 decryptAuthResponseV4(byte[] in, ECKey myKey); AuthResponseMessageV4 handleAuthResponseV4(ECKey myKey, byte[] initiatePacket, byte[] responsePacket); AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key); byte[] encryptAuthMessage(AuthInitiateMessage message); byte[] encryptAuthResponse(AuthResponseMessage message); AuthResponseMessage decryptAuthResponse(byte[] ciphertext, ECKey myKey); AuthInitiateMessage decryptAuthInitiate(byte[] ciphertext, ECKey myKey); AuthResponseMessage handleAuthResponse(ECKey myKey, byte[] initiatePacket, byte[] responsePacket); byte[] handleAuthInitiate(byte[] initiatePacket, ECKey key); static byte recIdFromSignatureV(int v); Secrets getSecrets(); ECPoint getRemotePublicKey(); boolean isInitiator(); static final int NONCE_SIZE; static final int MAC_SIZE; static final int SECRET_SIZE; }