Files
shadowdaoandClaude Sonnet 5.5 962d708fdd Rename Go module paths to repo.anhonesthost.net/CyberCoveLLC/threshold
Rename root, api and sdk module paths (imports, go.mod, go_package,
ldflags, build scripts, buf configs) and regenerate protobuf/gateway
code with the project's pinned toolchain. Wire identifiers unchanged.
api gets a local replace for sdk; root/api/sdk require v0.1.0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 10:33:41 -07:00

36 lines
1005 B
Go

// Copyright IBM Corp. 2020, 2026
// SPDX-License-Identifier: BUSL-1.1
package session
import (
"context"
"crypto/ed25519"
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/errors"
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/libs/crypto"
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
)
// DeriveED25519Key generates a key based on the project's session DEK, the
// requesting user, and the generated job ID.
func DeriveED25519Key(ctx context.Context, wrapper wrapping.Wrapper, userId, jobId string) (ed25519.PublicKey, ed25519.PrivateKey, error) {
const op = "session.DeriveED25519Key"
var uId, jId []byte
if userId != "" {
uId = []byte(userId)
}
if jobId != "" {
jId = []byte(jobId)
}
if wrapper == nil {
return nil, nil, errors.New(ctx, errors.InvalidParameter, op, "missing wrapper")
}
reader, err := crypto.NewDerivedReader(ctx, wrapper, 32, uId, jId)
if err != nil {
return nil, nil, errors.Wrap(ctx, err, op)
}
return ed25519.GenerateKey(reader)
}