Skip to content

Commit

Permalink
feat(rust): ockam_credential v0.1.0
Browse files Browse the repository at this point in the history
1. Bump version to v0.1.0
2. Improve documentation
3. Add Cargo.lock
4. Improve std, no-std and no-std with alloc handling
5. Add tests

Co-authored-by: Jared Stanbrough <[email protected]>
  • Loading branch information
mrinalwadhwa and Jared Stanbrough committed Feb 10, 2021
1 parent 6ad67d9 commit dc0441b
Show file tree
Hide file tree
Showing 12 changed files with 371 additions and 80 deletions.
9 changes: 4 additions & 5 deletions implementations/rust/ockam/ockam_credential/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ All notable changes to this crate will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.0.0 - 2021-02-05
## 0.1.0 - 2021-02-05
## Added

- Initial Release
- `Schema` - Describes a credentials attributes and context
- `Attribute` - Describes a claims data and labels
- `AttributeType` - Describes a claims data interpretation
- `Schema` - a credential's data layout.
- `Attribute` - a statement by the credential issuer about the credential subject.
- `AttributeType` - the data type of an attribute's value.
192 changes: 192 additions & 0 deletions implementations/rust/ockam/ockam_credential/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 19 additions & 14 deletions implementations/rust/ockam/ockam_credential/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
[package]
name = "ockam_credential"
version = "0.1.0"
authors = ["Ockam Developers"]
categories = []
description = ""
documentation = "https://docs.rs/ockam_credentials"
edition = "2018"
exclude = [
"tests/**"
]
homepage = "https://ockam.io"
keywords = []
license = "Apache-2.0"
name = "ockam_credential"
homepage = "https://github.com/ockam-network/ockam"
repository = "https://github.com/ockam-network/ockam/tree/develop/implementations/rust/ockam/ockam_credential"
readme = "README.md"
repository = "https://github.com/ockam-network/ockam/tree/develop/implementations/rust/ockam/ockam_credentials"
version = "0.0.0"
keywords = ["ockam", "authorization", "anonymous", "zero-knowledge", "credential"]
categories = ["cryptography", "no-std"]
description = """
Attribute based, privacy preserving, anonymous credentials.
"""
exclude = [
"DEVELOP.md",
"LICENSE"
]

[features]
default = ["std"]
std = ["ockam_core/std", "alloc"]
alloc = ["serde/alloc"]
no-std = ["heapless"]
std = ["alloc", "ockam_core/std"]
no_std = ["heapless"]

[dependencies]
ockam_core = { path = "../ockam_core", version = "0.2.0", default-features = false }
heapless = { version = "0.6", optional = true }
ockam_core = { version = "0.1.0", default-features = false, path = "../ockam_core" }
serde = { version = "1.0", default-features = false, features = ["derive"] }

[dev-dependencies]
serde_json = "1.0"
1 change: 1 addition & 0 deletions implementations/rust/ockam/ockam_credential/DEVELOP.md
1 change: 1 addition & 0 deletions implementations/rust/ockam/ockam_credential/LICENSE
48 changes: 30 additions & 18 deletions implementations/rust/ockam/ockam_credential/README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,62 @@
# ockam_credentials
# ockam_credential

[![crate][crate-image]][crate-link]
[![docs][docs-image]][docs-link]
[![license][license-image]][license-link]
[![discuss][discuss-image]][discuss-link]

Ockam Credentials is a library for describing, creating, and verifying credentials
on Ockam networks.
Ockam is a library for building devices that communicate securely, privately
and trustfully with cloud services and other devices.

This crate provides the ability to issue and verify attribute based,
privacy preserving, anonymous credentials.

The issuer of a credential signs a collection of statements that attest to
attributes of the subject of that credential. The subject (or a holder on
their behalf) can then selectively disclose these signed statements to a
verifier by presenting a cryptographic proof of knowledge of the issuer's
signature without revealing the actual signature or any of the other
statements that they didn't wish to disclose to this verifier.

Applications can decide if a subject is authorized to take an action based
on the attributes of the subject that were proven to be signed by trusted
issuers. Since only limited and necessary information is revealed about
subjects this improves efficiency, security and privacy of applications.

The main [Ockam][main-ockam-crate-link] crate re-exports types defined in
this crate.

## Usage

Add this to your `Cargo.toml`:

```
[dependencies]
ockam_credentials = "0.0.0"
ockam_credential = "0.1.0"
```

## Crate Features

The `ockam_credentials` crate has a Cargo feature named `"std"` that is enabled by
default. In order to use this crate in a `no-std` context this feature can
disabled as follows
The `ockam_credential` crate has a Cargo feature named `"std"` that is enabled by
default. In order to use this crate in a `"no_std"` context you can disable default
features and then enable the `"no_std"` feature as follows:

```
[dependencies]
ockam_credentials = { version = "0.0.0", default-features = false, features = ["no-std"] }
ockam_credential = { version = "0.1.0", default-features = false, features = ["no_std"] }
```

Please note that Cargo features are unioned across the entire dependency
graph of a project. If any other crate you depend on has not opted out of
`ockam_credentials` default features, Cargo will build `ockam_credentials` with the std
feature enabled whether or not your direct dependency on `ockam_credentials`
has `default-features = false`.

## License

This code is licensed under the terms of the [Apache License 2.0][license-link].

[main-ockam-crate-link]: https://crates.io/crates/ockam

[crate-image]: https://img.shields.io/crates/v/ockam_credentials.svg
[crate-link]: https://crates.io/crates/ockam_credentials
[crate-image]: https://img.shields.io/crates/v/ockam_credential.svg
[crate-link]: https://crates.io/crates/ockam_credential

[docs-image]: https://docs.rs/ockam_credentials/badge.svg
[docs-link]: https://docs.rs/ockam_credentials
[docs-image]: https://docs.rs/ockam_credential/badge.svg
[docs-link]: https://docs.rs/ockam_credential

[license-image]: https://img.shields.io/badge/License-Apache%202.0-green.svg
[license-link]: https://github.com/ockam-network/ockam/blob/HEAD/LICENSE
Expand Down
15 changes: 8 additions & 7 deletions implementations/rust/ockam/ockam_credential/src/attribute.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
use super::structs::*;
use crate::{attribute_type::AttributeType, serdes::*};
use crate::{attribute_type::AttributeType, serde::*};
use serde::{Deserialize, Serialize};

/// Attributes describe the claims in credentials. The attribute
/// describes the name of the claim,
/// its meaning and how it is cryptographically signed
/// An attribute describes a statement that the issuer of a credential is
/// signing about the subject of the credential.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Attribute {
/// The name of the attribute
/// A label for the attribute.
#[serde(
serialize_with = "write_byte_string",
deserialize_with = "read_byte_string"
)]
pub label: ByteString,
/// A longer description of the meaning of the attribute

/// A longer description of the meaning of the attribute.
#[serde(
serialize_with = "write_byte_string",
deserialize_with = "read_byte_string"
)]
pub description: ByteString,
/// The method that converts the attribute value to a cryptographic field element

/// The data type of the attribute value.
pub attribute_type: AttributeType,
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use serde::{Deserialize, Serialize};

/// A Mapper converts an arbitrary value to cryptographic field element
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
/// The data type of an attribute's value.
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
pub enum AttributeType {
/// The attribute is a UTF8 encoded string
/// The attribute is a UTF8 encoded string.
Utf8String,
/// The attribute is a number either real or an integer
/// The attribute is a number, either real or an integer.
Number,
/// The value is a byte sequence
/// The value is a byte sequence.
Blob,
}
Loading

0 comments on commit dc0441b

Please sign in to comment.