4 releases (2 breaking)

0.5.1 Oct 14, 2022
0.5.0 Oct 13, 2022
0.4.1 Oct 10, 2022
0.1.0 Apr 11, 2022

#7 in #multi-hash

Download history 413/week @ 2025-09-02 300/week @ 2025-09-09 329/week @ 2025-09-16 220/week @ 2025-09-23 535/week @ 2025-09-30 342/week @ 2025-10-07 279/week @ 2025-10-14 478/week @ 2025-10-21 212/week @ 2025-10-28 264/week @ 2025-11-04 192/week @ 2025-11-11 386/week @ 2025-11-18 340/week @ 2025-11-25 465/week @ 2025-12-02 376/week @ 2025-12-09 8/week @ 2025-12-16

1,203 downloads per month
Used in 17 crates (via rebase)

Apache-2.0

23KB
526 lines

CACAOs

CACAOs is a Rust library implementing the CAIP-74 Chain-Agnostic Object Capability Specification, with built in support for Sign In With Ethereum.

Example

A simple example using SIWE-type CACAOs:

use async_trait::async_trait;
use cacaos::{
    siwe_cacao::{Eip191, Eip4361, Payload, SiweCacao},
    SignatureScheme,
};
use futures::executor::block_on;
use hex::FromHex;
use libipld::{cbor::DagCborCodec, codec::Encode, multihash::Code, store::DefaultParams, Block};
use siwe::Message;
use std::str::FromStr;

async fn run_example() {
    let message: Payload = Message::from_str(
        r#"localhost:4361 wants you to sign in with your Ethereum account:
0x6Da01670d8fc844e736095918bbE11fE8D564163

SIWE Notepad Example

URI: http://localhost:4361
Version: 1
Chain ID: 1
Nonce: kEWepMt9knR6lWJ6A
Issued At: 2021-12-07T18:28:18.807Z"#,
    )
    .unwrap()
    .into();

    let sig = <Vec<u8>>::from_hex(r#"6228b3ecd7bf2df018183aeab6b6f1db1e9f4e3cbe24560404112e25363540eb679934908143224d746bbb5e1aa65ab435684081f4dbb74a0fec57f98f40f5051c"#).unwrap().try_into().unwrap();

    // verify a siwe signature
    let v = Eip191::verify(&message, &sig).await.unwrap();

    // sign the message to create a cacao
    let cacao: SiweCacao = SiweCacao::new(message, sig, None);

    // ipld-encode the cacao
    let block = Block::<DefaultParams>::encode(DagCborCodec, Code::Blake3_256, &cacao).unwrap();
}

fn main() {
    block_on(run_example());
}

`

Dependencies

~16MB
~286K SLoC