コード例 #1
0
 public static void CreateNew(ICryptoLibrary cryptoLibrary, out RegistrationPrivateKey privateKey, out RegistrationId registrationId)
 {
     privateKey = new RegistrationPrivateKey {
         ed25519privateKey = cryptoLibrary.GeneratePrivateKeyEd25519()
     };
     registrationId = new RegistrationId(cryptoLibrary.GetPublicKeyEd25519(privateKey.ed25519privateKey));
 }
コード例 #2
0
        public static RegistrationPrivateKey Decode(BinaryReader reader)
        {
            var flags = reader.ReadByte();

            if ((flags & FlagsMask_MustBeZero) != 0)
            {
                throw new NotImplementedException();
            }
            var r = new RegistrationPrivateKey {
                ed25519privateKey = reader.ReadBytes(CryptoLibraries.Ed25519PrivateKeySize)
            };

            return(r);
        }
コード例 #3
0
        public static LocalDrpPeerConfiguration  Create(ICryptoLibrary cryptoLibrary, int numberOfDimensions, byte[] ed25519privateKey = null, RegistrationId registrationId = null)
        {
            var privatekey = new RegistrationPrivateKey {
                ed25519privateKey = ed25519privateKey ?? cryptoLibrary.GeneratePrivateKeyEd25519()
            };
            var r = new LocalDrpPeerConfiguration
            {
                LocalPeerRegistrationPrivateKey = privatekey,
                LocalPeerRegistrationId         = new RegistrationId(registrationId?.Ed25519publicKey ?? cryptoLibrary.GetPublicKeyEd25519(privatekey.ed25519privateKey))
            };

            if (numberOfDimensions == 2)
            {
                r.MinDesiredNumberOfNeighbors  = 5;
                r.SoftMaxNumberOfNeighbors     = 7;
                r.AbsoluteMaxNumberOfNeighbors = 10;
            }
            return(r);
        }
コード例 #4
0
        public static RegistrationSignature Sign(ICryptoLibrary cryptoLibrary, Action <BinaryWriter> writeSignedFields, RegistrationPrivateKey privateKey)
        {
            var r  = new RegistrationSignature();
            var ms = new MemoryStream(); using (var writer = new BinaryWriter(ms)) writeSignedFields(writer);

            r.ed25519signature = cryptoLibrary.SignEd25519(
                ms.ToArray(),
                privateKey.ed25519privateKey);
            return(r);
        }