Skip to content

Commit

Permalink
docs(logic): re-generate documentation of predicates
Browse files Browse the repository at this point in the history
  • Loading branch information
ccamel committed Oct 27, 2023
1 parent cbc0400 commit e84d018
Showing 1 changed file with 77 additions and 1 deletion.
78 changes: 77 additions & 1 deletion docs/predicate/predicates.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e84d018

Please sign in to comment.