func (e *Engine) SignedEnvelope(ctx context.Context, body identity.Immutable,
	sigID *identity.ID, sigKP *SignatureKeyPair) (*envelope.Signed, error) {

	err := ctxutil.ErrIfDone(ctx)
	if err != nil {
		return nil, err
	}

	b, err := json.Marshal(&body)
	if err != nil {
		return nil, err
	}

	s, err := e.Sign(ctx, *sigKP, append([]byte(strconv.Itoa(body.Version())), b...))
	if err != nil {
		return nil, err
	}

	sig := primitive.Signature{
		PublicKeyID: sigID,
		Algorithm:   EdDSA,
		Value:       base64.NewValue(s),
	}

	id, err := identity.NewImmutable(body, &sig)
	if err != nil {
		return nil, err
	}

	return &envelope.Signed{
		ID:        &id,
		Version:   uint8(body.Version()),
		Body:      body,
		Signature: sig,
	}, nil
}
// SignedEnvelope returns a new SignedEnvelope containing body
SignedEnvelope returns a new SignedEnvelope containing body
// SignedEnvelope returns a new SignedEnvelope containing body
func (e *Engine) SignedEnvelope(ctx context.Context, body identity.Immutable,
	sigID *identity.ID, sigKP *SignatureKeyPair) (*envelope.Signed, error) {
	err := ctxutil.ErrIfDone(ctx)
	if err != nil {
		return nil, err
	}
	b, err := json.Marshal(&body)
	if err != nil {
		return nil, err
	}
	s, err := e.Sign(ctx, *sigKP, append([]byte(strconv.Itoa(body.Version())), b...))
	if err != nil {
		return nil, err
	}
	sig := primitive.Signature{
		PublicKeyID: sigID,
		Algorithm:   EdDSA,
		Value:       base64.NewValue(s),
	}
	id, err := identity.NewImmutable(body, &sig)
	if err != nil {
		return nil, err
	}
	return &envelope.Signed{
		ID:        &id,
		Version:   uint8(body.Version()),
		Body:      body,
		Signature: sig,
	}, nil
}
func ( e * Engine ) SignedEnvelope ( ctx context . Context , body identity . Immutable , sigID * identity . ID , sigKP * SignatureKeyPair ) ( * envelope . Signed , error ) { err := ctxutil . ErrIfDone ( ctx ) if err != nil { return nil , err } b , err := json . Marshal ( & body ) if err != nil { return nil , err } s , err := e . Sign ( ctx , * sigKP , append ( [ ] byte ( strconv . Itoa ( body . Version ( ) ) ) , b ... ) ) if err != nil { return nil , err } sig := primitive . Signature { PublicKeyID : sigID , Algorithm : EdDSA , Value : base64 . NewValue ( s ) , } id , err := identity . NewImmutable ( body , & sig ) if err != nil { return nil , err } return & envelope . Signed { ID : & id , Version : uint8 ( body . Version ( ) ) , Body : body , Signature : sig , } , nil }
SignedEnvelope returns a new SignedEnvelope containing body
SignedEnvelope returns a new SignedEnvelope containing body