public Ed25519PublicKeyParameters GeneratePublicKey() { lock (data) { if (null == cachedPublicKey) { byte[] publicKey = new byte[Ed25519.PublicKeySize]; Ed25519.GeneratePublicKey(data, 0, publicKey, 0); cachedPublicKey = new Ed25519PublicKeyParameters(publicKey, 0); } return(cachedPublicKey); } }
public void Sign(Ed25519.Algorithm algorithm, Ed25519PublicKeyParameters publicKey, byte[] ctx, byte[] msg, int msgOff, int msgLen, byte[] sig, int sigOff) { byte[] pk = new byte[Ed25519.PublicKeySize]; if (null == publicKey) { Ed25519.GeneratePublicKey(data, 0, pk, 0); } else { publicKey.Encode(pk, 0); } switch (algorithm) { case Ed25519.Algorithm.Ed25519: { if (null != ctx) { throw new ArgumentException("ctx"); } Ed25519.Sign(data, 0, pk, 0, msg, msgOff, msgLen, sig, sigOff); break; } case Ed25519.Algorithm.Ed25519ctx: { Ed25519.Sign(data, 0, pk, 0, ctx, msg, msgOff, msgLen, sig, sigOff); break; } case Ed25519.Algorithm.Ed25519ph: { if (Ed25519.PrehashSize != msgLen) { throw new ArgumentException("msgLen"); } Ed25519.SignPrehash(data, 0, pk, 0, ctx, msg, msgOff, sig, sigOff); break; } default: { throw new ArgumentException("algorithm"); } } }
public void Sign(Ed25519.Algorithm algorithm, Ed25519PublicKeyParameters publicKey, byte[] ctx, byte[] msg, int msgOff, int msgLen, byte[] sig, int sigOff) { Sign(algorithm, ctx, msg, msgOff, msgLen, sig, sigOff); }