nostr-did 0.1.6

Generate W3C-compliant DID Documents from did:nostr identifiers
Documentation
{
  "spec": "did:nostr",
  "version": "0.0.12",
  "description": "Conformance test vectors for the did:nostr method. Generated by the nostr-did Rust implementation (https://crates.io/crates/nostr-did).",
  "generatedBy": "nostr-did v0.1.3 (https://crates.io/crates/nostr-did)",
  "vectors": {
    "key_transformation": [
      {
        "name": "spec_example_2_5",
        "description": "The example public key from section 2.5 of the specification",
        "input": "124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
        "output": "fe70102124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
        "roundtrip": true
      },
      {
        "name": "all_zeros",
        "description": "All-zero public key (x=0 is a valid field element but not a point on the curve -- treated as opaque hex in default mode, rejected with crypto-validation)",
        "input": "0000000000000000000000000000000000000000000000000000000000000000",
        "output": "fe701020000000000000000000000000000000000000000000000000000000000000000",
        "roundtrip": true
      },
      {
        "name": "all_ones",
        "description": "All-ones public key (x >= p, not a valid secp256k1 field element -- treated as opaque hex in default mode, rejected with crypto-validation)",
        "input": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
        "output": "fe70102ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
        "roundtrip": true
      },
      {
        "name": "uppercase_input",
        "description": "Uppercase hex input should be accepted and normalized to lowercase output",
        "input": "124C0FA99407182ECE5A24FAD9B7F6674902FC422843D3128D38A0AFBEE0FDD2",
        "output": "fe70102124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
        "roundtrip": true
      },
      {
        "name": "mixed_case_input",
        "description": "Mixed case hex input should be accepted",
        "input": "124c0fa99407182ece5a24fAD9B7F6674902FC422843d3128d38a0afbee0fdd2",
        "output": "fe70102124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
        "roundtrip": true
      }
    ],
    "key_decoding": [
      {
        "name": "decode_even_parity",
        "description": "Decode a Multikey with even parity (0x02) -- canonical BIP-340 encoding",
        "input": "fe70102124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
        "output": "124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
        "parity": 2
      },
      {
        "name": "decode_odd_parity",
        "description": "Decode a Multikey with odd parity (0x03) -- same x-coordinate, other lift. Decoders accept both for interop; BIP-340 canonical decoder rejects odd parity.",
        "input": "fe70103124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
        "output": "124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
        "parity": 3
      }
    ],
    "error_cases": [
      {
        "name": "error_hex_too_short",
        "description": "Hex input shorter than 64 characters",
        "input": "abc123",
        "error": "InvalidHexLength"
      },
      {
        "name": "error_hex_too_long",
        "description": "Hex input longer than 64 characters",
        "input": "124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd20000",
        "error": "InvalidHexLength"
      },
      {
        "name": "error_hex_empty",
        "description": "Empty input",
        "input": "",
        "error": "InvalidHexLength"
      },
      {
        "name": "error_invalid_hex_character",
        "description": "Non-hex character in input",
        "input": "gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg",
        "error": "InvalidHexCharacter"
      },
      {
        "name": "error_x_not_field_element",
        "description": "x-coordinate >= field prime p -- rejected by crypto-validation",
        "input": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc30",
        "error": "InvalidPublicKey"
      },
      {
        "name": "error_x_not_on_curve",
        "description": "x-coordinate < p but not a point on the curve (x=0) -- rejected by crypto-validation",
        "input": "0000000000000000000000000000000000000000000000000000000000000000",
        "error": "InvalidPublicKey"
      },
      {
        "name": "error_odd_parity_in_bip340_decoder",
        "description": "BIP-340 canonical decoder rejects odd parity",
        "input": "fe70103124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
        "error": "OddParityNotCanonical"
      },
      {
        "name": "error_wrong_multicodec",
        "description": "Multikey with incorrect multicodec prefix",
        "input": "f000102124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
        "error": "InvalidMulticodec"
      },
      {
        "name": "error_invalid_multibase_prefix",
        "description": "Multikey without 'f' prefix",
        "input": "abc123",
        "error": "InvalidMultibase"
      },
      {
        "name": "error_uppercase_multibase_prefix",
        "description": "Multikey with uppercase 'F' prefix (only lowercase 'f' is valid base16-lower)",
        "input": "FE70102124C0FA99407182ECE5A24FAD9B7F6674902FC422843D3128D38A0AFBEE0FDD2",
        "error": "InvalidMultibase"
      },
      {
        "name": "error_invalid_key_length",
        "description": "Multikey with truncated key data",
        "input": "fe70102",
        "error": "InvalidKeyLength"
      }
    ],
    "did_document_generation": [
      {
        "name": "minimal_document_2_3_1",
        "description": "Section 2.3.1 -- Minimal DID Document (offline resolution, verification method only)",
        "input": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
        "output": {
          "@context": [
            "https://www.w3.org/ns/cid/v1",
            "https://w3id.org/nostr/context"
          ],
          "assertionMethod": [
            "#key1"
          ],
          "authentication": [
            "#key1"
          ],
          "id": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
          "type": "DIDNostr",
          "verificationMethod": [
            {
              "controller": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
              "id": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2#key1",
              "publicKeyMultibase": "fe70102124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
              "type": "Multikey"
            }
          ]
        }
      },
      {
        "name": "enhanced_document_2_3_2",
        "description": "Section 2.3.2 -- Enhanced DID Document with relay service endpoints",
        "input": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
        "output": {
          "@context": [
            "https://www.w3.org/ns/cid/v1",
            "https://w3id.org/nostr/context"
          ],
          "assertionMethod": [
            "#key1"
          ],
          "authentication": [
            "#key1"
          ],
          "id": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
          "modified": "2025-01-26T15:50:00Z",
          "service": [
            {
              "id": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2#relay1",
              "serviceEndpoint": "wss://relay.damus.io/",
              "type": "Relay"
            },
            {
              "id": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2#relay2",
              "serviceEndpoint": "wss://nos.lol/",
              "type": "Relay"
            }
          ],
          "type": "DIDNostr",
          "verificationMethod": [
            {
              "controller": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
              "id": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2#key1",
              "publicKeyMultibase": "fe70102124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
              "type": "Multikey"
            }
          ]
        }
      },
      {
        "name": "complete_document_2_3_3",
        "description": "Section 2.3.3 -- Complete DID Document with profile, alsoKnownAs, and follows",
        "input": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
        "output": {
          "@context": [
            "https://www.w3.org/ns/cid/v1",
            "https://w3id.org/nostr/context"
          ],
          "alsoKnownAs": [
            "https://alice.example.com/#me",
            "https://social.example.com/@alice",
            "at://alice.bsky.social"
          ],
          "assertionMethod": [
            "#key1"
          ],
          "authentication": [
            "#key1"
          ],
          "follows": [
            "did:nostr:32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245",
            "did:nostr:46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184147700e3a8"
          ],
          "id": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
          "modified": "2025-01-26T15:50:00Z",
          "profile": {
            "about": "Building the decentralized web",
            "created_at": 1737906600,
            "lud16": "alice@getalby.com",
            "name": "Alice",
            "nip05": "alice@example.com",
            "picture": "https://example.com/alice.jpg",
            "website": "https://alice.example.com"
          },
          "service": [
            {
              "id": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2#relay1",
              "serviceEndpoint": "wss://relay.damus.io/",
              "type": "Relay"
            }
          ],
          "type": "DIDNostr",
          "verificationMethod": [
            {
              "controller": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
              "id": "did:nostr:124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2#key1",
              "publicKeyMultibase": "fe70102124c0fa99407182ece5a24fad9b7f6674902fc422843d3128d38a0afbee0fdd2",
              "type": "Multikey"
            }
          ]
        }
      }
    ]
  }
}