Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Zheng <[email protected]>
  • Loading branch information
Two-Hearts committed Dec 25, 2024
1 parent 1b1caac commit a9c2119
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions example_signBlob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (
"github.com/notaryproject/notation-go/signer"
)

// ExampleSignBlob demonstrates how to use [signer.BlobSign] to sign arbitrary
// ExampleSignBlob demonstrates how to use [notation.SignBlob] to sign arbitrary
// data.
func Example_signBlob() {
// exampleSigner implements [notation.Signer] and [notation.BlobSigner].
// Given key and X509 certificate chain, it provides method to sign OCI
// artifacts or blobs.
// Users should replace `exampleCertTuple.PrivateKey` with their own private
// key and replace `exampleCerts` with the corresponding certificate chain,
//following the Notary Project certificate requirements:
// following the Notary Project certificate requirements:
// https://github.com/notaryproject/notaryproject/blob/v1.0.0/specs/signature-specification.md#certificate-requirements
exampleSigner, err := signer.NewGenericSigner(exampleCertTuple.PrivateKey, exampleCerts)
if err != nil {
Expand All @@ -44,7 +44,7 @@ func Example_signBlob() {
exampleSignatureMediaType := jws.MediaTypeEnvelope
exampleContentMediaType := "video/mp4"

// exampleSignOptions is an example of notation.SignBlobOptions.
// exampleSignOptions is an example of [notation.SignBlobOptions].
exampleSignOptions := notation.SignBlobOptions{
SignerSignOptions: notation.SignerSignOptions{
SignatureMediaType: exampleSignatureMediaType,
Expand All @@ -54,7 +54,8 @@ func Example_signBlob() {
UserMetadata: map[string]string{"buildId": "101"},
}

// exampleReader reads the data that needs to be signed. This data can be in a file or in memory.
// exampleReader reads the data that needs to be signed.
// This data can be in a file or in memory.
exampleReader := strings.NewReader("example blob")

// Upon successful signing, signature envelope and signerInfo are returned.
Expand Down
8 changes: 4 additions & 4 deletions example_verifyBlob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var exampleBlobPolicyDocument = trustpolicy.BlobDocument{
},
}

// ExampleVerifyBlob demonstrates how to use [verifier.Verify] to verify a
// ExampleVerifyBlob demonstrates how to use [notation.VerifyBlob] to verify a
// signature of an arbitrary blob.
func Example_verifyBlob() {
// Both COSE ("application/cose") and JWS ("application/jose+json")
Expand All @@ -53,7 +53,7 @@ func Example_verifyBlob() {
exampleSignatureEnvelope := getSignatureEnvelope()

// createTrustStoreForBlobVerify creates a trust store directory for demo purpose.
// Users could use the default trust store from Notation and add trusted
// Users could use the default trust store from Notary Project and add trusted
// certificates into it following the trust store spec:
// https://github.com/notaryproject/notaryproject/blob/v1.1.0/specs/trust-store-trust-policy.md#trust-store
if err := createTrustStoreForBlobVerify(); err != nil {
Expand All @@ -70,7 +70,7 @@ func Example_verifyBlob() {
// This data can be in a file or in memory.
exampleReader := strings.NewReader("example blob")

// exampleVerifyOptions is an example of [notation.VerifierVerifyOptions]
// exampleVerifyOptions is an example of [notation.VerifyBlobOptions]
exampleVerifyOptions := notation.VerifyBlobOptions{
BlobVerifierVerifyOptions: notation.BlobVerifierVerifyOptions{
SignatureMediaType: exampleSignatureMediaType,
Expand All @@ -92,7 +92,7 @@ func Example_verifyBlob() {

// Note, upon successful verification, payload.TargetArtifact from the
// signature envelope matches exactly with our exampleTargetDescriptor.
// (This check has been done for the user inside [verifier.Verify].)
// (This check has been done for the user inside verifier.Verify.)
fmt.Println("payload Content:", string(outcome.EnvelopeContent.Payload.Content))

// Output:
Expand Down

0 comments on commit a9c2119

Please sign in to comment.