コード例 #1
0
        public static EcdhTuple EcdhDecode(this EcdhTuple mask, byte[] recieverSK)
        {
            EcdhTuple unmask = mask;

            byte[] sharedSec1 = Cryptography.Crypto.Default.Hash256(ScalarFunctions.MulWithPoint(mask.senderPK, recieverSK));
            byte[] sharedSec2 = Cryptography.Crypto.Default.Hash256(sharedSec1);

            unmask.mask   = ScalarFunctions.Sub(mask.mask, sharedSec1);
            unmask.amount = ScalarFunctions.Sub(mask.amount, sharedSec2);

            return(unmask);
        }
コード例 #2
0
        public static EcdhTuple EcdhEncode(this EcdhTuple unmask, ECPoint receiverPk)
        {
            EcdhTuple ret = new EcdhTuple();

            byte[] esk = SchnorrNonLinkable.GenerateRandomScalar();
            ret.senderPK = ECCurve.Secp256r1.G * esk;

            byte[] sharedSec1 = Cryptography.Crypto.Default.Hash256(ScalarFunctions.MulWithPoint(receiverPk, esk));
            byte[] sharedSec2 = Cryptography.Crypto.Default.Hash256(sharedSec1);

            ret.mask   = ScalarFunctions.Add(unmask.mask, sharedSec1);
            ret.amount = ScalarFunctions.Add(unmask.amount, sharedSec2);
            return(ret);
        }