From 555ff3292a85a136de32191c3bd6a42cfb71012b Mon Sep 17 00:00:00 2001 From: Igor Matsak Date: Mon, 10 Aug 2020 19:02:45 +0300 Subject: [PATCH] Added signing with extended key for Ed25519 --- crypto/src/math/ec/rfc8032/Ed25519.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crypto/src/math/ec/rfc8032/Ed25519.cs b/crypto/src/math/ec/rfc8032/Ed25519.cs index 95ba434728..4706184b5c 100644 --- a/crypto/src/math/ec/rfc8032/Ed25519.cs +++ b/crypto/src/math/ec/rfc8032/Ed25519.cs @@ -1100,6 +1100,21 @@ public static void SignPrehash(byte[] sk, int skOff, byte[] pk, int pkOff, byte[ ImplSign(sk, skOff, pk, pkOff, ctx, phflag, m, 0, m.Length, sig, sigOff); } + public static void SignByExtendedKey(byte[] h, byte[] ctx, byte[] m, int mOff, int mLen, byte[] sig, int sigOff) + { + byte phflag = 0x00; + + byte[] s = new byte[ScalarBytes]; + PruneScalar(h, 0, s); + + byte[] pk = new byte[PointBytes]; + ScalarMultBaseEncoded(s, pk, 0); + + IDigest d = CreateDigest(); + + ImplSign(d, h, s, pk, 0, ctx, phflag, m, mOff, mLen, sig, sigOff); + } + public static bool Verify(byte[] sig, int sigOff, byte[] pk, int pkOff, byte[] m, int mOff, int mLen) { byte[] ctx = null;