SignStatement signs the provided statement with the named key. The key needs to be previously generated with the functionality from the crypto package.
(ctx context.Context, keyName string, statement any)
| 112 | // SignStatement signs the provided statement with the named key. The key needs |
| 113 | // to be previously generated with the functionality from the crypto package. |
| 114 | func SignStatement(ctx context.Context, keyName string, statement any) ([]byte, error) { |
| 115 | payload, err := json.Marshal(statement) |
| 116 | if err != nil { |
| 117 | return nil, err |
| 118 | } |
| 119 | |
| 120 | signer, err := crypto.SignerWithKey(ctx, keyName) |
| 121 | if err != nil { |
| 122 | return nil, err |
| 123 | } |
| 124 | |
| 125 | dsseSigner := dsse.WrapSigner(signer, types.IntotoPayloadType) |
| 126 | |
| 127 | return dsseSigner.SignMessage(bytes.NewReader(payload), options.WithContext(ctx)) |
| 128 | } |
no test coverage detected