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)); }
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); }
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); }
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); }