OpenAgentID documentation
Source referencesRust module referenceoas-crypto

oas-crypto · encoding

Declared module signatures, types, configuration, and source documentation.

Source: oas/oas/oas-crypto/src/encoding.rs. SHA-256: b10d5dd33a132cb8711b3595e6b0f999666d9c74eb5d27f02637159a7e0d4b52.

This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.

encoding::multibase_encode

Encodes bytes as multibase base58btc with the z prefix.

This is the canonical encoding for Ed25519 public keys in OAS Identity Documents and AgentLineageProof2025 structures.

Arguments

  • bytes - The raw bytes to encode.

Returns

A string with the z prefix followed by base58btc-encoded data.

Examples

use oas_crypto::encoding::multibase_encode;

let encoded = multibase_encode(&[1, 2, 3]);
assert!(encoded.starts_with('z'));
pub fn multibase_encode(bytes: &[u8]) -> String;

Source line: 31.

encoding::multibase_decode

Decodes a multibase base58btc string (with z prefix) into raw bytes.

Arguments

  • encoded - A multibase-encoded string that MUST start with z.

Returns

The decoded raw bytes.

Errors

Returns [CryptoError::MultibaseDecodeFailed] if:

  • The string does not start with z
  • The base58btc decoding fails

Examples

use oas_crypto::encoding::{multibase_encode, multibase_decode};

let original = vec![1, 2, 3, 4, 5];
let encoded = multibase_encode(&original);
let decoded = multibase_decode(&encoded).unwrap();
assert_eq!(original, decoded);
pub fn multibase_decode(encoded: &str) -> Result<Vec<u8>, CryptoError>;

Source line: 64.

encoding::base64url_encode

Encodes bytes as base64url without padding (RFC 4648 §5).

This is the canonical encoding for Ed25519 signatures in OAS.

Arguments

  • bytes - The raw bytes to encode.

Returns

A base64url-encoded string without padding.

Examples

use oas_crypto::encoding::base64url_encode;

let encoded = base64url_encode(&[1, 2, 3]);
assert!(!encoded.contains('='));
pub fn base64url_encode(bytes: &[u8]) -> String;

Source line: 101.

encoding::base64url_decode

Decodes a base64url string (RFC 4648 §5) into raw bytes.

Accepts input with or without padding.

Arguments

  • encoded - A base64url-encoded string.

Returns

The decoded raw bytes.

Errors

Returns [CryptoError::Base64DecodeFailed] if the input is not valid base64url.

Examples

use oas_crypto::encoding::{base64url_encode, base64url_decode};

let original = vec![10, 20, 30, 40, 50];
let encoded = base64url_encode(&original);
let decoded = base64url_decode(&encoded).unwrap();
assert_eq!(original, decoded);
pub fn base64url_decode(encoded: &str) -> Result<Vec<u8>, CryptoError>;

Source line: 133.

On this page