From e84d018797f3a13320f4859c726b45f41ef35535 Mon Sep 17 00:00:00 2001 From: ccamel Date: Fri, 27 Oct 2023 17:47:22 +0200 Subject: [PATCH] docs(logic): re-generate documentation of predicates --- docs/predicate/predicates.md | 78 +++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/docs/predicate/predicates.md b/docs/predicate/predicates.md index d5ec691f..7c7412cf 100644 --- a/docs/predicate/predicates.md +++ b/docs/predicate/predicates.md @@ -198,7 +198,83 @@ Examples: - did_components('did:example:123456?versionId=1', did(Method, ID, Path, Query, Fragment)). # Reconstruct a DID from its components. -- did_components(DID, did('example', '123456', null, 'versionId=1', _42)). +- did_components(DID, did('example', '123456', _, 'versionId=1', _42)). +``` + +## ecdsa_verify/4 + +ecdsa_verify/4 determines if a given signature is valid as per the ECDSA algorithm for the provided data, using the specified public key. + +The signature is as follows: + +```text +ecdsa_verify(+PubKey, +Data, +Signature, +Options), which is semi-deterministic. +``` + +Where: + +- PubKey is the 33\-byte compressed public key, as specified in section 4.3.6 of ANSI X9.62. + +- Data is the hash of the signed message, which can be either an atom or a list of bytes. + +- Signature represents the ASN.1 encoded signature corresponding to the Data. + +- Options are additional configurations for the verification process. Supported options include: encoding\(\+Format\) which specifies the encoding used for the data, and type\(\+Alg\) which chooses the algorithm within the ECDSA family \(see below for details\). + +For Format, the supported encodings are: + +- hex \(default\), the hexadecimal encoding represented as an atom. +- octet, the plain byte encoding depicted as a list of integers ranging from 0 to 255. + +For Alg, the supported algorithms are: + +- secp256r1 \(default\): Also known as P\-256 and prime256v1. +- secp256k1: The Koblitz elliptic curve used in Bitcoin's public\-key cryptography. + +Examples: + +```text +# Verify a signature for hexadecimal data using the ECDSA secp256r1 algorithm. +- ecdsa_verify([127, ...], '9b038f8ef6918cbb56040dfda401b56b...', [23, 56, ...], encoding(hex)) + +# Verify a signature for binary data using the ECDSA secp256k1 algorithm. +- ecdsa_verify([127, ...], [56, 90, ..], [23, 56, ...], [encoding(octet), type(secp256k1)]) +``` + +## eddsa_verify/4 + +eddsa_verify/4 determines if a given signature is valid as per the EdDSA algorithm for the provided data, using the specified public key. + +The signature is as follows: + +```text +eddsa_verify(+PubKey, +Data, +Signature, +Options) is semi-det +``` + +Where: + +- PubKey is the encoded public key as a list of bytes. +- Data is the message to verify, represented as either a hexadecimal atom or a list of bytes. It's important that the message isn't pre\-hashed since the Ed25519 algorithm processes messages in two passes when signing. +- Signature represents the signature corresponding to the data, provided as a list of bytes. +- Options are additional configurations for the verification process. Supported options include: encoding\(\+Format\) which specifies the encoding used for the Data, and type\(\+Alg\) which chooses the algorithm within the EdDSA family \(see below for details\). + +For Format, the supported encodings are: + +- hex \(default\), the hexadecimal encoding represented as an atom. +- octet, the plain byte encoding depicted as a list of integers ranging from 0 to 255. + +For Alg, the supported algorithms are: + +- ed25519 \(default\): The EdDSA signature scheme using SHA\-512 \(SHA\-2\) and Curve25519. + +Examples: + +```text +# Verify a signature for a given hexadecimal data. +- eddsa_verify([127, ...], '9b038f8ef6918cbb56040dfda401b56b...', [23, 56, ...], [encoding(hex), type(ed25519)]) + +# Verify a signature for binary data. +- eddsa_verify([127, ...], [56, 90, ..], [23, 56, ...], [encoding(octet), type(ed25519)]) ``` ## hex_bytes/2