public static byte[] DeriveX3DhSecretReceiver(Curve25519KeyPair selfIdentityKeyPair,
                                                      Curve25519KeyPair selfSignedPreKeyPair, Curve25519KeyPair otherIdentityKey, Curve25519KeyPair ephemeralKey,
                                                      Curve25519KeyPair selfOneTimePreKeyPair = null)
        {
            byte[] dh1 = selfSignedPreKeyPair.CalculateSharedSecret(otherIdentityKey);
            byte[] dh2 = selfIdentityKeyPair.CalculateSharedSecret(ephemeralKey);
            byte[] dh3 = selfSignedPreKeyPair.CalculateSharedSecret(ephemeralKey);

            IEnumerable <byte> dhConcat = dh1.Concat(dh2).Concat(dh3);

            if (!(selfOneTimePreKeyPair is null))
            {
                byte[] dh4 = selfOneTimePreKeyPair.CalculateSharedSecret(ephemeralKey);
                dhConcat = dhConcat.Concat(dh4);
            }

            return(X3DhKdf(dhConcat.ToArray(), X3DhProtocolInfo));
        }
Пример #2
0
 public byte[] CalculateSharedSecret(Curve25519KeyPair otherKey)
 {
     return(CalculateSharedSecret(otherKey.XPublicKey));
 }
 public static byte[] CalculateInitialAssociatedData(Curve25519KeyPair identityKeyA,
                                                     Curve25519KeyPair identityKeyB)
 {
     return(identityKeyA.XPublicKey.Concat(identityKeyB.XPublicKey).ToArray());
 }