@@ -27,35 +27,48 @@ This crate provides high-level APIs for creating Sigstore signatures. It orchest
2727## Usage
2828
2929``` rust
30- use sigstore_sign :: {Signer , SigningConfig };
30+ use sigstore_sign :: {SigningContext , Attestation , AttestationSubject };
31+ use sigstore_oidc :: IdentityToken ;
32+ use sigstore_types :: Sha256Hash ;
3133
32- let config = SigningConfig :: production ();
33- let signer = Signer :: new ( config ) . await ? ;
34+ // Create a signing context for production
35+ let context = SigningContext :: production () ;
3436
35- // Sign a blob
36- let bundle = signer . sign ( artifact_bytes ) . await ? ;
37+ // Get an identity token (from OIDC provider)
38+ let token = IdentityToken :: new ( " your-identity-token " . to_string ()) ;
3739
38- // Sign with a DSSE envelope
39- let bundle = signer . sign_dsse (payload_type , payload ). await ? ;
40+ // Create a signer
41+ let signer = context . signer (token );
42+
43+ // Sign artifact bytes
44+ let artifact = b " hello world" ;
45+ let bundle = signer . sign (artifact ). await ? ;
46+
47+ // Or sign with a pre-computed digest (for large files)
48+ let digest = Sha256Hash :: from_hex (" b94d27b9..." )? ;
49+ let bundle = signer . sign (digest ). await ? ;
50+
51+ // Sign an in-toto attestation (DSSE envelope)
52+ let subject = AttestationSubject :: new (" artifact.tar.gz" , digest );
53+ let attestation = Attestation :: new (" https://slsa.dev/provenance/v1" )
54+ . with_subject (subject )
55+ . with_predicate (serde_json :: json! ({" key" : " value" }));
56+ let bundle = signer . sign_attestation (attestation ). await ? ;
57+
58+ // Write bundle to file
59+ std :: fs :: write (" artifact.sigstore.json" , bundle . to_json_pretty ()? )? ;
4060```
4161
4262## Configuration
4363
4464``` rust
45- use sigstore_sign :: SigningConfig ;
65+ use sigstore_sign :: SigningContext ;
4666
47- // Production (default)
48- let config = SigningConfig :: production ();
67+ // Production environment
68+ let context = SigningContext :: production ();
4969
5070// Staging environment
51- let config = SigningConfig :: staging ();
52-
53- // Custom configuration
54- let config = SigningConfig {
55- fulcio_url : " https://fulcio.example.com" . into (),
56- rekor_url : " https://rekor.example.com" . into (),
57- // ...
58- };
71+ let context = SigningContext :: staging ();
5972```
6073
6174## Related Crates
0 commit comments