public Pair <RootKey, ChainKey> CreateChain(IEcPublicKey theirRatchetKey, EcKeyPair ourRatchetKey) { byte[] sharedSecret = Curve.CalculateAgreement(theirRatchetKey, ourRatchetKey.GetPrivateKey()); byte[] derivedSecretBytes = _kdf.DeriveSecrets(sharedSecret, _key, Encoding.UTF8.GetBytes("WhisperRatchet"), DerivedRootSecrets.Size); DerivedRootSecrets derivedSecrets = new DerivedRootSecrets(derivedSecretBytes); RootKey newRootKey = new RootKey(_kdf, derivedSecrets.GetRootKey()); ChainKey newChainKey = new ChainKey(_kdf, derivedSecrets.GetChainKey(), 0); return(new Pair <RootKey, ChainKey>(newRootKey, newChainKey)); }
public Pair <RootKey, ChainKey> createChain(ECPublicKey theirRatchetKey, ECKeyPair ourRatchetKey) { byte[] sharedSecret = Curve.calculateAgreement(theirRatchetKey, ourRatchetKey.getPrivateKey()); byte[] derivedSecretBytes = kdf.deriveSecrets(sharedSecret, key, Encoding.UTF8.GetBytes("WhisperRatchet"), DerivedRootSecrets.SIZE); DerivedRootSecrets derivedSecrets = new DerivedRootSecrets(derivedSecretBytes); RootKey newRootKey = new RootKey(kdf, derivedSecrets.getRootKey()); ChainKey newChainKey = new ChainKey(kdf, derivedSecrets.getChainKey(), 0); return(new Pair <RootKey, ChainKey>(newRootKey, newChainKey)); }