go-blockchain/crypto/keyimage.go
Snider 34128d8e98
Some checks failed
Security Scan / security (pull_request) Successful in 11s
Test / Test (pull_request) Failing after 19s
refactor: migrate module path to dappco.re/go/core/blockchain
Update go.mod module line, all require/replace directives, and every
.go import path from forge.lthn.ai/core/go-blockchain to
dappco.re/go/core/blockchain. Add replace directives to bridge
dappco.re paths to existing forge.lthn.ai registry during migration.
Update CLAUDE.md, README, and docs to reflect the new module path.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 01:49:26 +00:00

34 lines
858 B
Go

// SPDX-Licence-Identifier: EUPL-1.2
package crypto
/*
#include "bridge.h"
*/
import "C"
import (
"unsafe"
coreerr "dappco.re/go/core/log"
)
// GenerateKeyImage computes the key image for a public/secret key pair.
// The key image is used for double-spend detection in ring signatures.
func GenerateKeyImage(pub [32]byte, sec [32]byte) ([32]byte, error) {
var ki [32]byte
rc := C.cn_generate_key_image(
(*C.uint8_t)(unsafe.Pointer(&pub[0])),
(*C.uint8_t)(unsafe.Pointer(&sec[0])),
(*C.uint8_t)(unsafe.Pointer(&ki[0])),
)
if rc != 0 {
return ki, coreerr.E("GenerateKeyImage", "generate_key_image failed", nil)
}
return ki, nil
}
// ValidateKeyImage checks that a key image is a valid curve point of the correct order.
func ValidateKeyImage(ki [32]byte) bool {
return C.cn_validate_key_image((*C.uint8_t)(unsafe.Pointer(&ki[0]))) == 0
}