sqisign

package module
v0.0.0-...-7e27dd1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

README

SQISign-Go

This is a repository for Go bindinds of the SQISign algorithm made in C using CGo, forked from Zinho02.

Getting Started

First, clone the sqisign-go repository:

$ git clone git@github.com:PQC-Group-UTFPR/sqisign-go.git

Usage

package main

import (
	"fmt"
	"github.com/PQC-Group-UTFPR/sqisign-go"
)

func main() {
	message := []byte("message to be signed")

	// Generate a new key pair
	pub, priv, err := sqisign.GenerateKey()
	if err != nil {
		panic(err)
	}

	fmt.Printf("Public key: %x\n", pub.Bytes())
	fmt.Printf("Private key: %x\n", priv.Bytes())

	signature, err := priv.Sign(nil, message, nil)
	if err != nil {
		panic(err)
	}

	fmt.Println("Message: ", string(message))
	fmt.Printf("Signature: %x\n", signature)

	err = pub.Verify(message, signature)
	if err != nil {
		fmt.Println("Invalid signature")
	} else {
		fmt.Println("Valid signature")
	}
}

API

The sqisign-go binding provides functions for key management and cryptographic operations. The key types, PublicKey and PrivateKey, implement the crypto.PublicKey and crypto.Signer interfaces from the Go standard library.

  • func GenerateKey() (*PublicKey, *PrivateKey, error)
  • func PublicKeyFromBytes(data []byte) (*PublicKey, error)
  • func PrivateKeyFromBytes(data []byte) (*PrivateKey, error)
  • func (pub *PublicKey) Bytes() []byte
  • func (priv *PrivateKey) Bytes() []byte
  • func (priv *PrivateKey) Public() crypto.PublicKey
  • func (priv *PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) (signature []byte, error)
  • func (pub *PublicKey) Verify(digest, signature []byte) error

[!WARNING] The PrivateKeyFromBytes() function deserializes a private key but DOES NOT reconstruct its corresponding public key. As result, in this case, calling priv.Public() will return nil.

Running the tests

$ go test -v .

The tests cover key generation, signing, verification with valid and invalid signatures, and key serialization/deserialization.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CRYPTO_ALGNAME string = C.CRYPTO_ALGNAME
View Source
var CRYPTO_BYTES int = C.CRYPTO_BYTES
View Source
var CRYPTO_PUBLICKEYBYTES int = C.CRYPTO_PUBLICKEYBYTES
View Source
var CRYPTO_SECRETKEYBYTES int = C.CRYPTO_SECRETKEYBYTES
View Source
var C_CRYPTO_BYTES C.int = C.CRYPTO_BYTES
View Source
var C_CRYPTO_PUBLICKEYBYTES C.int = C.CRYPTO_PUBLICKEYBYTES
View Source
var C_CRYPTO_SECRETKEYBYTES C.int = C.CRYPTO_SECRETKEYBYTES

Functions

func CryptoSign

func CryptoSign(sm *C.uchar, smlen *C.ulonglong, m *C.uchar,
	mlen C.ulonglong, sk *C.uchar) int

func CryptoSignKeyPair

func CryptoSignKeyPair(pk *C.uchar, sk *C.uchar) int

func CryptoSignOpen

func CryptoSignOpen(m *C.uchar, mlen *C.ulonglong, sm *C.uchar,
	smlen C.ulonglong, pk *C.uchar) int

func GenerateKey

func GenerateKey() (pk *PublicKey, sk *PrivateKey, err error)

func PrintHex

func PrintHex(data []byte)

Types

type PrivateKey

type PrivateKey struct {
	// contains filtered or unexported fields
}

func PrivateKeyFromBytes

func PrivateKeyFromBytes(data []byte) (*PrivateKey, error)

func (*PrivateKey) Bytes

func (priv *PrivateKey) Bytes() []byte

func (*PrivateKey) Public

func (priv *PrivateKey) Public() crypto.PublicKey

func (*PrivateKey) Sign

func (priv *PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) (signature []byte, err error)

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

func PublicKeyFromBytes

func PublicKeyFromBytes(data []byte) (*PublicKey, error)

func (*PublicKey) Bytes

func (pub *PublicKey) Bytes() []byte

func (*PublicKey) Verify

func (pub *PublicKey) Verify(digest, signature []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL