Class Sas
- All Implemented Interfaces:
AutoCloseable
The verification process is heavily inspired by Phil Zimmermann's ZRTP
key agreement handshake. A core part of key agreement in ZRTP is the
hash commitment: the party that begins the key sharing process sends
a hash of their part of the Diffie-Hellman exchange but does not send
the part itself until they have received the other party's part.
The verification process can be used to verify the Ed25519 identity key of
an Account.
This class implements AutoCloseable and should be used in a
try-with-resources block to ensure native resources are properly released.
- Author:
- François HERBRETEAU
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondiffieHellman(String theirPublicKey) Establishes a SAS secret by performing a Diffie-Hellman handshake with another public key.Returns the public key that can be used to establish a shared secret.Methods inherited from class NativeHandle
checkNotClosed, close, invalidate, nativePtr
-
Constructor Details
-
Sas
public Sas()Creates a new random verification object.This creates an ephemeral curve25519 keypair that can be used to establish a shared secret.
-
-
Method Details
-
publicKey
Returns the public key that can be used to establish a shared secret.- Returns:
- the base64-encoded public key
- Throws:
IllegalStateException- if thisSashas been closed or consumed bydiffieHellman(String)
-
diffieHellman
Establishes a SAS secret by performing a Diffie-Hellman handshake with another public key.This method consumes the
Sasobject — after this call, theSasis invalidated and can no longer be used. The native resources are transferred to the returnedEstablishedSas.- Parameters:
theirPublicKey- a base64-encoded Curve25519 public key- Returns:
- a new
EstablishedSaswhich can be used to generateSasBytesand calculate MACs - Throws:
IllegalStateException- if thisSashas already been closed or consumedKeyException- if the given public key is invalid or cannot be decoded
-