bovine.crypto.helper
content_digest_sha256(content)
Computes the SHA256 digest of given content
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content |
str | bytes
|
Content to be encoded |
required |
Source code in bovine/bovine/crypto/helper.py
content_digest_sha256_rfc_9530(content)
Computes the content digest according to RFC 9530
>>> content_digest_sha256_rfc_9530(b'{"hello": "world"}\n')
('content-digest', 'sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:')
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content |
bytes
|
Usually the request body to compute the digest from |
required |
Returns:
Type | Description |
---|---|
Tuple[str, str]
|
Tuple of header name, header value |
Source code in bovine/bovine/crypto/helper.py
ensure_data_integrity_context(doc)
Performs context injection according to
Verifiable Credentials: Data Integrity. The data integrity
context being added is https://w3id.org/security/data-integrity/v2
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doc |
dict
|
Document |
required |
Returns:
Type | Description |
---|---|
dict
|
The same document with the data integrity context added. |
Source code in bovine/bovine/crypto/helper.py
jcs_sha256(doc, context=None)
Returns the sha256 digest of the representation
of dict according to JCS. This assumes that doc
is JSON serializable.
JCS is defined in RFC8785.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doc |
dict
|
The document |
required |
context |
dict | None
|
ignored used in rdfc_sha256 |
None
|
Source code in bovine/bovine/crypto/helper.py
jcs_sha384(doc, context=None)
Returns the sha384 digest of the representation
of dict according to JCS. This assumes that doc
is JSON serializable.
JCS is defined in RFC8785.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doc |
dict
|
The document |
required |
context |
dict | None
|
ignored used in rdfc_sha256 |
None
|
Source code in bovine/bovine/crypto/helper.py
public_key_to_did_key(public_key)
Converts a public key to a did:key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
public_key |
Union[Ed25519PublicKey, RSAPublicKey, EllipticCurvePublicKey]
|
The public key |
required |
Source code in bovine/bovine/crypto/helper.py
rdfc_sha256(doc, context={})
Returns the sha256 digest of the representation of dict according to RDF-Canon
The algorithm used is URDNA2015 and the result are n-quads.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doc |
dict
|
The document |
required |
context |
dict
|
If doc has no |
{}
|
Source code in bovine/bovine/crypto/helper.py
rdfc_sha384(doc, context={})
Returns the sha384 digest of the representation of dict according to RDF-Canon
The algorithm used is URDNA2015 and the result are n-quads.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doc |
dict
|
The document |
required |
context |
dict
|
If doc has no |
{}
|