From 702ff466fb9e54e7aeb6af7aa9a8211b0d1689a6 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 27 Feb 2025 14:26:44 +0300 Subject: [PATCH] *: Support Neo N3 auth scheme This adds new `refs.SignatureScheme` enum value making any `refs.Signature` field work as N3 witness. The `refs.SignatureRFC6979` is updated the same. This feature will allow authentication and authorization with multi-signatures and contract-based accounts. Closes #305. Signed-off-by: Leonard Lyubich --- proto-docs/refs.md | 9 +++++---- refs/types.proto | 14 ++++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/proto-docs/refs.md b/proto-docs/refs.md index 27222e0..f1f25ac 100644 --- a/proto-docs/refs.md +++ b/proto-docs/refs.md @@ -149,8 +149,8 @@ Signature of something in NeoFS. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| key | [bytes](#bytes) | | Public key used for signing | -| sign | [bytes](#bytes) | | Signature | +| key | [bytes](#bytes) | | Public key used for signing. For N3 `scheme`, the field represents a verification script. | +| sign | [bytes](#bytes) | | Signature. For N3 `scheme`, the field represents an invocation script. | | scheme | [SignatureScheme](#neo.fs.v2.refs.SignatureScheme) | | Scheme contains digital signature scheme identifier | @@ -162,8 +162,8 @@ RFC 6979 signature. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| key | [bytes](#bytes) | | Public key used for signing | -| sign | [bytes](#bytes) | | Deterministic ECDSA with SHA-256 hashing | +| key | [bytes](#bytes) | | Public key used for signing. For N3 auth scheme, the field represents a verification script. | +| sign | [bytes](#bytes) | | Deterministic ECDSA with SHA-256 hashing. For N3 auth scheme, the field represents an invocation script. | @@ -223,6 +223,7 @@ Signature scheme describes digital signing scheme used for (key, signature) pair | ECDSA_SHA512 | 0 | ECDSA with SHA-512 hashing (FIPS 186-3) | | ECDSA_RFC6979_SHA256 | 1 | Deterministic ECDSA with SHA-256 hashing (RFC 6979) | | ECDSA_RFC6979_SHA256_WALLET_CONNECT | 2 | Deterministic ECDSA with SHA-256 hashing using WalletConnect API. Here the algorithm is the same, but the message format differs. | +| N3 | 3 | Neo N3 witness. | diff --git a/refs/types.proto b/refs/types.proto index 9be849b..c5bb99d 100644 --- a/refs/types.proto +++ b/refs/types.proto @@ -105,9 +105,10 @@ message Version { // Signature of something in NeoFS. message Signature { - // Public key used for signing + // Public key used for signing. For N3 `scheme`, the field represents a + // verification script. bytes key = 1 [json_name = "key"]; - // Signature + // Signature. For N3 `scheme`, the field represents an invocation script. bytes sign = 2 [json_name = "signature"]; // Scheme contains digital signature scheme identifier SignatureScheme scheme = 3 [json_name = "scheme"]; @@ -124,13 +125,18 @@ enum SignatureScheme { // Deterministic ECDSA with SHA-256 hashing using WalletConnect API. // Here the algorithm is the same, but the message format differs. ECDSA_RFC6979_SHA256_WALLET_CONNECT = 2; + + // Neo N3 witness. + N3 = 3; } // RFC 6979 signature. message SignatureRFC6979 { - // Public key used for signing + // Public key used for signing. For N3 auth scheme, the field represents a + // verification script. bytes key = 1 [json_name = "key"]; - // Deterministic ECDSA with SHA-256 hashing + // Deterministic ECDSA with SHA-256 hashing. For N3 auth scheme, the field + // represents an invocation script. bytes sign = 2 [json_name = "signature"]; }