Skip to content

Commit

Permalink
update signatures and package
Browse files Browse the repository at this point in the history
Signed-off-by: bytemare <3641580+bytemare@users.noreply.github.com>
  • Loading branch information
bytemare committed Oct 3, 2024
1 parent b673ec1 commit 08142fe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
7 changes: 3 additions & 4 deletions element.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
// SPDX-License-Identifier: MIT
//
// Copyright (C) 2020-2023 Daniel Bourdrez. All Rights Reserved.
// Copyright (C) 2020-2024 Daniel Bourdrez. All Rights Reserved.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree or at
// https://spdx.org/licenses/MIT.html

// Package crypto exposes a prime-order elliptic curve groups with additional hash-to-curve operations.
package crypto
package ecc

import (
"fmt"
"strings"

"github.com/bytemare/crypto/internal"
"github.com/bytemare/ecc/internal"
)

// Element represents an element on the curve of the prime-order group.
Expand Down
22 changes: 11 additions & 11 deletions groups.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
// SPDX-License-Group: MIT
//
// Copyright (C) 2020-2023 Daniel Bourdrez. All Rights Reserved.
// Copyright (C) 2020-2024 Daniel Bourdrez. All Rights Reserved.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree or at
// https://spdx.org/licenses/MIT.html

// Package crypto exposes a prime-order elliptic curve groups with additional hash-to-curve operations.
// Package ecc exposes a prime-order elliptic curve groups with additional hash-to-curve operations.
//
// It implements the latest hash-to-curve specification to date
// (https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve/).
package crypto
package ecc

import (
"crypto"
"errors"
"fmt"
"sync"

"github.com/bytemare/crypto/internal"
"github.com/bytemare/crypto/internal/edwards25519"
"github.com/bytemare/crypto/internal/nist"
"github.com/bytemare/crypto/internal/ristretto"
"github.com/bytemare/crypto/internal/secp256k1"
"github.com/bytemare/ecc/internal"
"github.com/bytemare/ecc/internal/edwards25519"
"github.com/bytemare/ecc/internal/nist"
"github.com/bytemare/ecc/internal/ristretto"
"github.com/bytemare/ecc/internal/secp256k1"
)

// Group identifies prime-order groups over elliptic curves with hash-to-group operations.
Expand All @@ -47,8 +47,8 @@ const (
// Edwards25519Sha512 identifies the Edwards25519 group with SHA2-512 hash-to-group hashing.
Edwards25519Sha512

// Secp256k1 identifies the SECp256k1 group with SHA2-256 hash-to-group hashing.
Secp256k1
// Secp256k1Sha256 identifies the SECp256k1 group with SHA2-256 hash-to-group hashing.
Secp256k1Sha256

maxID

Expand Down Expand Up @@ -171,7 +171,7 @@ func (g Group) init() {
g.initGroup(nist.P521)
case Edwards25519Sha512:
g.initGroup(edwards25519.New)
case Secp256k1:
case Secp256k1Sha256:
g.initGroup(secp256k1.New)
default:
panic("group not recognized")
Expand Down
13 changes: 6 additions & 7 deletions scalar.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
// SPDX-License-Identifier: MIT
//
// Copyright (C) 2020-2023 Daniel Bourdrez. All Rights Reserved.
// Copyright (C) 2020-2024 Daniel Bourdrez. All Rights Reserved.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree or at
// https://spdx.org/licenses/MIT.html

// Package crypto exposes a prime-order elliptic curve groups with additional hash-to-curve operations.
package crypto
package ecc

import (
"fmt"
"strings"

"github.com/bytemare/crypto/internal"
"github.com/bytemare/ecc/internal"
)

// Scalar represents a scalar in the prime-order group.
Expand Down Expand Up @@ -116,12 +115,12 @@ func (s *Scalar) Equal(scalar *Scalar) bool {
}

// LessOrEqual returns 1 if s <= scalar, and 0 otherwise.
func (s *Scalar) LessOrEqual(scalar *Scalar) int {
func (s *Scalar) LessOrEqual(scalar *Scalar) bool {
if scalar == nil {
return 0
return false
}

return s.Scalar.LessOrEqual(scalar.Scalar)
return s.Scalar.LessOrEqual(scalar.Scalar) == 1
}

// IsZero returns whether the scalar is 0.
Expand Down

0 comments on commit 08142fe

Please sign in to comment.