- server: relay storing signed objects (PUT/GET), per-IP rate limiting, per-subject quota (1000), one-response-per-request, pagination, /v1/healthz /v1/readyz /v1/metrics - verify: signature-verifying trust evaluator; every object is checked via env.Verify(), approvals via VerifyApprovalResponse, revocations via VerifyRevocationOf; k-of-n approval quorum - docs: TRUST-MODEL.md and API.md describing issuer-anchored signatures and the endpoint/status-code contract - tests: server, verify, and ratelimit packages
30 lines
859 B
Go
30 lines
859 B
Go
package address_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/btcsuite/btcd/btcutil/bech32"
|
|
|
|
"git.n1ko.dev/Niko/niko_trust/internal/address"
|
|
)
|
|
|
|
// encodeRawForTest builds a syntactically valid bech32m trust address around
|
|
// an arbitrary payload, bypassing the validation that FromPubKey performs.
|
|
//
|
|
// It exists so that tests can construct the strings an attacker would send and
|
|
// confirm that Parse rejects them. Production code must never do this.
|
|
func encodeRawForTest(t *testing.T, version byte, key []byte) string {
|
|
t.Helper()
|
|
payload := make([]byte, 0, 1+len(key))
|
|
payload = append(payload, version)
|
|
payload = append(payload, key...)
|
|
conv, err := bech32.ConvertBits(payload, 8, 5, true)
|
|
if err != nil {
|
|
t.Fatalf("convert bits: %v", err)
|
|
}
|
|
s, err := bech32.EncodeM(address.HRP, conv)
|
|
if err != nil {
|
|
t.Fatalf("encode: %v", err)
|
|
}
|
|
return s
|
|
}
|