// Copyright (C) 2024 Vaughn Nugent // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . using System; using VNLib.Utils.Cryptography.Noscrypt.Encryption; namespace VNLib.Utils.Cryptography.Noscrypt { public interface INostrCrypto { /// /// Gets a nostr public key from a secret key. /// /// A reference to the secret key to get the public key from /// A reference to the public key structure to write the recovered key to /// /// void GetPublicKey(ref readonly NCSecretKey secretKey, ref NCPublicKey publicKey); /// /// Validates a secret key is in a valid format. /// /// A readonly reference to key structure to validate /// True if the key is consiered valid against the secp256k1 curve /// /// bool ValidateSecretKey(ref readonly NCSecretKey secretKey); /// /// Allocates a new cipher instance with the supplied options. /// /// The cipher specification version /// The cipher initialziation flags /// The cipher instance NoscryptCipher AllocCipher(NoscryptCipherVersion version, NoscryptCipherFlags flags); /// /// Signs the supplied data with the secret key and random32 nonce, then writes /// the message signature to the supplied sig64 buffer. /// /// The secret key used to sign the message /// A highly secure random nonce used to seed the signature /// A pointer to the first byte in the message to sign /// The size of the message in bytes /// A pointer to the first byte of a 64 byte buffer used to write the message signature to /// /// void SignData( ref readonly NCSecretKey secretKey, ref readonly byte random32, ref readonly byte data, uint dataSize, ref byte sig64 ); /// /// Performs cryptographic verification of the supplied data /// against the supplied public key. /// /// The signer's public key /// A pointer to the first byte in the message to sign /// The number of bytes in the message /// A pointer to the signature buffer /// True if the signature could be verified against the public key. False otherwise /// /// bool VerifyData( ref readonly NCPublicKey pubKey, ref readonly byte data, uint dataSize, ref readonly byte sig64 ); } }