Links

Identities and Credentials

Ockam Identities are cryptographically verifiable digital identities. Each Identity has a unique Identifier. An Ockam Credential is a signed attestation by an Issuer about the Attributes of a Subject.

Identities

Ockam Identities are cryptographically verifiable digital identities. Each Identity maintains one or more secret keys and has a unique Ockam Identifier.
When an Ockam Identity is first created, it generates a random primary secret key inside an Ockam Vault. This secret key must be capable of performing a ChangeSignature. We support two types of change signatures - EdDSACurve25519Signature or ECDSASHA256CurveP256Signature. When both options are supported by a vault implementation that EdDSACurve25519Signature is our preferred option.
The public part of the primary secret key is then written into a Change (see data structure below) and this Change includes a signature using the primary secret key. The SHA256 hash of this first Change, truncated to its first 20 bytes, becomes the the forever Ockam Identifier of this Identity. Each change includes a created_at timestamp to indicate when the change was created and an expires_at timestamp to indicate when the primary_public_key included in the change should stop being relied on as the primary public key of this identity.
Whenever the identity wishes to rotate to a new primary public key and revoke all previous primary public keys it can create a new Change. This new change includes two signatures - one by the previous primary secret key and another by a newly generated primary secret key. Over time, this creates a signed ChangeHistory, the latest Change in this history indicates the self-attested latest primary public key of this Identity.
Note the green lines that indicate which signature is verified by which public key.
1
#[derive(Encode, Decode)]
2
#[cbor(transparent)]
3
pub struct Identifier(#[cbor(n(0), with = "minicbor::bytes")] pub [u8; 20]);
4
5
/// SHA256 hash of a Change, truncated to its first 20 bytes.
6
#[derive(Encode, Decode)]
7
#[cbor(transparent)]
8
pub struct ChangeHash(#[cbor(n(0), with = "minicbor::bytes")] pub [u8; 20]);
9
10
#[derive(Encode, Decode)]
11
#[cbor(transparent)]
12
pub struct ChangeHistory(#[n(0)] pub Vec<Change>);
13
14
#[derive(Encode, Decode)]
15
pub struct Change {
16
#[cbor(with = "minicbor::bytes")]
17
#[n(0)]
18
pub data: Vec<u8>,
19
20
#[n(1)]
21
pub signature: ChangeSignature,
22
23
#[n(2)]
24
pub previous_signature: Option<ChangeSignature>,
25
}
26
27
#[derive(Encode, Decode)]
28
pub enum ChangeSignature {
29
#[n(0)]
30
EdDSACurve25519(#[n(0)] EdDSACurve25519Signature),
31
32
#[n(1)]
33
ECDSASHA256CurveP256(#[n(0)] ECDSASHA256CurveP256Signature),
34
}
35
36
#[derive(Encode, Decode)]
37
pub struct ChangeData {
38
#[n(0)]
39
pub previous_change: Option<ChangeHash>,
40
41
#[n(1)]
42
pub primary_public_key: PrimaryPublicKey,
43
44
#[n(2)]
45
pub revoke_all_purpose_keys: bool,
46
47
#[n(3)]
48
pub created_at: TimestampInSeconds,
49
50
#[n(4)]
51
pub expires_at: TimestampInSeconds,
52
}
53
54
#[derive(Encode, Decode)]
55
pub enum PrimaryPublicKey {
56
#[n(0)]
57
EdDSACurve25519(#[n(0)] EdDSACurve25519PublicKey),
58
59
#[n(1)]
60
ECDSASHA256CurveP256(#[n(0)] ECDSASHA256CurveP256PublicKey),
61
}
62
63
#[derive(Encode, Decode)]
64
pub struct VersionedData {
65
#[n(0)]
66
pub version: u8,
67
68
#[cbor(with = "minicbor::bytes")]
69
#[n(1)]
70
pub data: Vec<u8>,
71
}
72
73
#[derive(Encode, Decode)]
74
#[cbor(transparent)]
75
pub struct TimestampInSeconds(#[n(0)] pub u64);

Purpose Key Attestations

An Ockam Identity can use its primary secret key to sign PurposeKeyAttestations (see data structure below). These attestations indicate which public keys (and corresponding secret keys) the identity wishes to use for issuing credentials and authenticating itself within secure channels.
Each attestation includes an expires_at timestamp to indicate when the included public key should no longer be relied on for its indicated purpose. The Identity's ChangeHistory can include a Change which has revoke_all_purpose_keys set to true. All purpose key attestations created before the created_at timestamp of this change are also be considered expired.
Note the green lines that indicate which signature is verified by which public key.
1
#[derive(Encode, Decode)]
2
pub struct PurposeKeyAttestation {
3
#[cbor(with = "minicbor::bytes")]
4
#[n(0)]
5
pub data: Vec<u8>,
6
7
#[n(1)]
8
pub signature: PurposeKeyAttestationSignature,
9
}
10
11
#[derive(Encode, Decode)]
12
pub enum PurposeKeyAttestationSignature {
13
#[n(0)]
14
EdDSACurve25519(#[n(0)] EdDSACurve25519Signature),
15
16
#[n(1)]
17
ECDSASHA256CurveP256(#[n(0)] ECDSASHA256CurveP256Signature),
18
}
19
20
#[derive(Encode, Decode)]
21
pub struct PurposeKeyAttestationData {
22
#[n(0)]
23
pub subject: Identifier,
24
25
#[n(1)]
26
pub subject_latest_change_hash: ChangeHash,
27
28
#[n(2)]
29
pub public_key: PurposePublicKey,
30
31
#[n(3)]
32
pub created_at: TimestampInSeconds,
33
34
#[n(4)]
35
pub expires_at: TimestampInSeconds,
36
}
37
38
#[derive(Encode, Decode)]
39
pub enum PurposePublicKey {
40
#[n(0)]
41
SecureChannelStatic(#[n(0)] X25519PublicKey),
42
43
#[n(1)]
44
CredentialSigning(#[n(0)] VerifyingPublicKey),
45
}

Credentials

An Ockam Credential is a signed attestation by an Issuer about the Attributes of a Subject. The Issuer and Subject are both Ockam Identities. Attributes is a map of name and value pairs.
Any Identity can issue credentials attesting to attributes of another Ockam Identity. This does not imply that these attestations should be considered authoritative about the subject's attributes. Who is an authority on which attributes of which subjects is defined using Ockam Trust Contexts.
Each signed credential includes an expires_at field to indicate a timestamp beyond which the attestation made in the credential should no longer be relied on.
Note the green lines that indicate which signature is verified by which public key.
1
#[derive(Encode, Decode)]
2
pub struct Credential {
3
#[cbor(with = "minicbor::bytes")]
4
#[n(0)]
5
pub data: Vec<u8>,
6
7
#[n(1)]
8
pub signature: CredentialSignature,
9
}
10
11
#[derive(Encode, Decode)]
12
pub enum CredentialSignature {
13
#[n(0)]
14
EdDSACurve25519(#[n(0)] EdDSACurve25519Signature),
15
16
#[n(1)]
17
ECDSASHA256CurveP256(#[n(0)] ECDSASHA256CurveP256Signature),
18
}
19
20
#[derive(Encode, Decode)]
21
pub struct CredentialData {
22
#[n(0)]
23
pub subject: Option<Identifier>,
24
25
#[n(1)]
26
pub subject_latest_change_hash: Option<ChangeHash>,
27
28
#[n(2)]
29
pub subject_attributes: Attributes,
30
31
#[n(3)]
32
pub created_at: TimestampInSeconds,
33
34
#[n(4)]
35
pub expires_at: TimestampInSeconds,
36
}
37
38
#[derive(Encode, Decode)]
39
#[cbor(transparent)]
40
pub struct CredentialSchemaIdentifier(#[n(0)] pub u64);
41
42
#[derive(Encode, Decode)]
43
pub struct Attributes {
44
#[n(0)]
45
pub schema: CredentialSchemaIdentifier,
46
47
#[n(1)]
48
pub map: BTreeMap<Vec<u8>, Vec<u8>>,
49
}
The Attributes type above includes a schema identifier that refers to a schema that defines the meaning of each attribute. For example, Project Membership Authorities within an Ockam Orchestrator Project use a specific schema identifier and define attributes like enroller which indicates that an Identity that possess a credential with enroller attribute set to true can request one-time user enrollment tokens to invite new members to the project.