Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Merge go1.19 branch to master #1269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 50 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a0b7135
Update Go version to 1.19.13 to begin work on Go 1.19 support.
nevkontakte Nov 12, 2023
c146af0
updated reflect and reflectlite
grantnelson-wf Nov 14, 2023
5090ba1
Merge pull request #1250 from Workiva/reflectUpdate
nevkontakte Nov 14, 2023
a76a603
Fixing a mistake found in reflect
grantnelson-wf Dec 4, 2023
528f1c8
Merge branch 'master' of github.com:gopherjs/gopherjs into reflectFix
grantnelson-wf Dec 4, 2023
0eb9c04
Merge pull request #1253 from Workiva/reflectFix
nevkontakte Dec 6, 2023
5edefc6
Update FuncKey and fix Http native
grantnelson-wf Dec 18, 2023
17263fa
Broke up parseAndAugment
grantnelson-wf Dec 18, 2023
6e1ec66
Extending Directives
grantnelson-wf Dec 18, 2023
9bcf242
Merge branch 'breakupAugment' of github.com:Workiva/gopherjs into add…
grantnelson-wf Dec 18, 2023
295da69
Merge branch 'extendDirectives' of github.com:Workiva/gopherjs into a…
grantnelson-wf Dec 18, 2023
27e1297
Adding purge directive
grantnelson-wf Dec 18, 2023
022eb64
Merge pull request #1255 from Workiva/updateFuncKey
nevkontakte Dec 19, 2023
f34e28b
Merge pull request #1256 from Workiva/breakupAugment
nevkontakte Dec 19, 2023
84774ae
Changed to use Inspect
grantnelson-wf Dec 19, 2023
b13f4d5
Merge branch 'go1.19' of github.com:gopherjs/gopherjs into addPurgeDi…
grantnelson-wf Dec 19, 2023
40bddb9
Merge branch 'extendDirectives' of github.com:Workiva/gopherjs into a…
grantnelson-wf Dec 19, 2023
7758c0d
Updated to use Inspect and srctesting
grantnelson-wf Dec 19, 2023
8ea6531
Merge pull request #1257 from Workiva/extendDirectives
nevkontakte Dec 21, 2023
bf0e797
Merge branch 'go1.19' of github.com:gopherjs/gopherjs into addPurgeDi…
grantnelson-wf Dec 29, 2023
38b4d3b
Merge pull request #1258 from Workiva/addPurgeDirective
nevkontakte Dec 29, 2023
e03bfea
Update compiler for go1.19
grantnelson-wf Jan 16, 2024
5f9eeb8
Fix Build Issue
grantnelson-wf Jan 16, 2024
a83c5fa
Updating natives for go1.19
grantnelson-wf Jan 16, 2024
cd17b90
Merge pull request #1261 from Workiva/updateCompiler19
nevkontakte Jan 19, 2024
5a98043
Updating documentation for build directives
grantnelson-wf Jan 19, 2024
1faba3b
Merge pull request #1260 from Workiva/fixBuildIssue
nevkontakte Jan 19, 2024
dea4768
Merge pull request #1262 from Workiva/updateNatives19
nevkontakte Jan 19, 2024
12a247d
Fix problem where import is named but source is augmented to only nee…
grantnelson-wf Jan 30, 2024
4b5b077
Fix chocolatey go version
grantnelson-wf Jan 30, 2024
d7abc77
Update known fails list of fixed bugs
grantnelson-wf Jan 30, 2024
95c01fa
Merge pull request #1263 from Workiva/go1.19BuildFix
nevkontakte Jan 30, 2024
91f1d44
Updated crypto natives
grantnelson-wf Jan 31, 2024
f5c911a
Fix natives for debug/pe
grantnelson-wf Jan 31, 2024
ff493e4
Update to go/token/position
grantnelson-wf Jan 31, 2024
cd055c9
Update hash/maphash
grantnelson-wf Jan 31, 2024
5437642
Update to reflect and reflectlite
grantnelson-wf Jan 31, 2024
8151b28
Update for fastrand
grantnelson-wf Jan 31, 2024
014360b
Updated net/netip
grantnelson-wf Jan 31, 2024
db5d7b3
Updating sync/atomic
grantnelson-wf Jan 31, 2024
710fdb7
Merge branch 'go1.19' of github.com:gopherjs/gopherjs into go1.19Nati…
grantnelson-wf Jan 31, 2024
a6b98dd
Update syscall/js
grantnelson-wf Jan 31, 2024
967ffcc
Fixed a copy/paste mistake
grantnelson-wf Jan 31, 2024
9e28c32
Merge pull request #1264 from Workiva/go1.19NativesUpdate
nevkontakte Jan 31, 2024
c08b7bf
Fixed chocolatey go version
grantnelson-wf Feb 13, 2024
02aea33
Limit augmentation and prune imports to natives that need it
grantnelson-wf Feb 13, 2024
c852920
Merge pull request #1266 from Workiva/forceChocolateyGoVersion
nevkontakte Feb 13, 2024
5d25518
Merge branch 'go1.19' of github.com:gopherjs/gopherjs into limitAugme…
grantnelson-wf Feb 13, 2024
a533e78
Merge pull request #1267 from Workiva/limitAugmentation
nevkontakte Feb 13, 2024
1011858
Update GopherJS version to 1.19.0-beta1 in perparation for release.
nevkontakte Feb 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions 81 compiler/natives/src/crypto/elliptic/nistec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//go:build js
// +build js

package elliptic

import (
"crypto/internal/nistec"
"math/big"
)

// nistPoint uses generics so must be removed for generic-less GopherJS.
// All the following code changes in this file are to make p224, p256,
// p521, and p384 still function correctly without this generic struct.
//
//gopherjs:purge for go1.19 without generics
type nistPoint[T any] interface{}

// nistCurve replaces the generics with a version using the wrappedPoint
// interface, then update all the method signatures to also use wrappedPoint.
type nistCurve struct {
newPoint func() nistec.WrappedPoint
params *CurveParams
}

//gopherjs:override-signature
func (curve *nistCurve) Params() *CurveParams

//gopherjs:override-signature
func (curve *nistCurve) IsOnCurve(x, y *big.Int) bool

//gopherjs:override-signature
func (curve *nistCurve) pointFromAffine(x, y *big.Int) (p nistec.WrappedPoint, err error)

//gopherjs:override-signature
func (curve *nistCurve) pointToAffine(p nistec.WrappedPoint) (x, y *big.Int)

//gopherjs:override-signature
func (curve *nistCurve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)

//gopherjs:override-signature
func (curve *nistCurve) Double(x1, y1 *big.Int) (*big.Int, *big.Int)

//gopherjs:override-signature
func (curve *nistCurve) normalizeScalar(scalar []byte) []byte

//gopherjs:override-signature
func (curve *nistCurve) ScalarMult(Bx, By *big.Int, scalar []byte) (*big.Int, *big.Int)

//gopherjs:override-signature
func (curve *nistCurve) ScalarBaseMult(scalar []byte) (*big.Int, *big.Int)

//gopherjs:override-signature
func (curve *nistCurve) CombinedMult(Px, Py *big.Int, s1, s2 []byte) (x, y *big.Int)

//gopherjs:override-signature
func (curve *nistCurve) Unmarshal(data []byte) (x, y *big.Int)

//gopherjs:override-signature
func (curve *nistCurve) UnmarshalCompressed(data []byte) (x, y *big.Int)

var p224 = &nistCurve{
newPoint: nistec.NewP224WrappedPoint,
}

type p256Curve struct {
nistCurve
}

var p256 = &p256Curve{
nistCurve: nistCurve{
newPoint: nistec.NewP256WrappedPoint,
},
}

var p521 = &nistCurve{
newPoint: nistec.NewP521WrappedPoint,
}

var p384 = &nistCurve{
newPoint: nistec.NewP384WrappedPoint,
}
42 changes: 42 additions & 0 deletions 42 compiler/natives/src/crypto/internal/boring/bbig/big.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//go:build js
// +build js

package bbig

import (
"crypto/internal/boring"
"math/big"
)

func Enc(b *big.Int) boring.BigInt {
if b == nil {
return nil
}
x := b.Bits()
if len(x) == 0 {
return boring.BigInt{}
}
// Replacing original which uses unsafe:
// return unsafe.Slice((*uint)(&x[0]), len(x))
b2 := make(boring.BigInt, len(x))
for i, w := range x {
b2[i] = uint(w)
}
return b2
}

func Dec(b boring.BigInt) *big.Int {
if b == nil {
return nil
}
if len(b) == 0 {
return new(big.Int)
}
// Replacing original which uses unsafe:
//x := unsafe.Slice((*big.Word)(&b[0]), len(b))
x := make([]big.Word, len(b))
for i, w := range b {
x[i] = big.Word(w)
}
return new(big.Int).SetBits(x)
}
88 changes: 88 additions & 0 deletions 88 compiler/natives/src/crypto/internal/nistec/nistec_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
//go:build js
// +build js

package nistec_test

import (
"crypto/elliptic"
"testing"
)

func TestAllocations(t *testing.T) {
t.Skip("testing.AllocsPerRun not supported in GopherJS")
}

//gopherjs:purge
type nistPoint[T any] interface{}

func TestEquivalents(t *testing.T) {
t.Run("P224", func(t *testing.T) {
testEquivalents(t, nistec.NewP224WrappedPoint, nistec.NewP224WrappedGenerator, elliptic.P224())
})
t.Run("P256", func(t *testing.T) {
testEquivalents(t, nistec.NewP256WrappedPoint, nistec.NewP256WrappedGenerator, elliptic.P256())
})
t.Run("P384", func(t *testing.T) {
testEquivalents(t, nistec.NewP384WrappedPoint, nistec.NewP384WrappedGenerator, elliptic.P384())
})
t.Run("P521", func(t *testing.T) {
testEquivalents(t, nistec.NewP521WrappedPoint, nistec.NewP521WrappedGenerator, elliptic.P521())
})
}

//gopherjs:override-signature
func testEquivalents(t *testing.T, newPoint, newGenerator func() WrappedPoint, c elliptic.Curve) {}

func TestScalarMult(t *testing.T) {
t.Run("P224", func(t *testing.T) {
testScalarMult(t, nistec.NewP224WrappedPoint, nistec.NewP224WrappedGenerator, elliptic.P224())
})
t.Run("P256", func(t *testing.T) {
testScalarMult(t, nistec.NewP256WrappedPoint, nistec.NewP256WrappedGenerator, elliptic.P256())
})
t.Run("P384", func(t *testing.T) {
testScalarMult(t, nistec.NewP384WrappedPoint, nistec.NewP384WrappedGenerator, elliptic.P384())
})
t.Run("P521", func(t *testing.T) {
testScalarMult(t, nistec.NewP521WrappedPoint, nistec.NewP521WrappedGenerator, elliptic.P521())
})
}

//gopherjs:override-signature
func testScalarMult(t *testing.T, newPoint, newGenerator func() WrappedPoint, c elliptic.Curve)

func BenchmarkScalarMult(b *testing.B) {
b.Run("P224", func(b *testing.B) {
benchmarkScalarMult(b, nistec.NewP224WrappedGenerator(), 28)
})
b.Run("P256", func(b *testing.B) {
benchmarkScalarMult(b, nistec.NewP256GWrappedenerator(), 32)
})
b.Run("P384", func(b *testing.B) {
benchmarkScalarMult(b, nistec.NewP384WrappedGenerator(), 48)
})
b.Run("P521", func(b *testing.B) {
benchmarkScalarMult(b, nistec.NewP521WrappedGenerator(), 66)
})
}

//gopherjs:override-signature
func benchmarkScalarMult(b *testing.B, p WrappedPoint, scalarSize int)

func BenchmarkScalarBaseMult(b *testing.B) {
b.Run("P224", func(b *testing.B) {
benchmarkScalarBaseMult(b, nistec.NewP22Wrapped4Generator(), 28)
})
b.Run("P256", func(b *testing.B) {
benchmarkScalarBaseMult(b, nistec.NewP256WrappedGenerator(), 32)
})
b.Run("P384", func(b *testing.B) {
benchmarkScalarBaseMult(b, nistec.NewP384WrappedGenerator(), 48)
})
b.Run("P521", func(b *testing.B) {
benchmarkScalarBaseMult(b, nistec.NewP521GWrappedenerator(), 66)
})
}

//gopherjs:override-signature
func benchmarkScalarBaseMult(b *testing.B, p WrappedPoint, scalarSize int)
185 changes: 185 additions & 0 deletions 185 compiler/natives/src/crypto/internal/nistec/wrapper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
//go:build js
// +build js

package nistec

type WrappedPoint interface {
Bytes() []byte
SetBytes(b []byte) (WrappedPoint, error)
Add(w1, w2 WrappedPoint) WrappedPoint
Double(w1 WrappedPoint) WrappedPoint
ScalarMult(w1 WrappedPoint, scalar []byte) (WrappedPoint, error)
ScalarBaseMult(scalar []byte) (WrappedPoint, error)
}

type p224Wrapper struct {
point *P224Point
}

func wrapP224(point *P224Point) WrappedPoint {
return p224Wrapper{point: point}
}

func NewP224WrappedPoint() WrappedPoint {
return wrapP224(NewP224Point())
}

func NewP224WrappedGenerator() WrappedPoint {
return wrapP224(NewP224Generator())
}

func (w p224Wrapper) Bytes() []byte {
return w.point.Bytes()
}

func (w p224Wrapper) SetBytes(b []byte) (WrappedPoint, error) {
p, err := w.point.SetBytes(b)
return wrapP224(p), err
}

func (w p224Wrapper) Add(w1, w2 WrappedPoint) WrappedPoint {
return wrapP224(w.point.Add(w1.(p224Wrapper).point, w2.(p224Wrapper).point))
}

func (w p224Wrapper) Double(w1 WrappedPoint) WrappedPoint {
return wrapP224(w.point.Double(w1.(p224Wrapper).point))
}

func (w p224Wrapper) ScalarMult(w1 WrappedPoint, scalar []byte) (WrappedPoint, error) {
p, err := w.point.ScalarMult(w1.(p224Wrapper).point, scalar)
return wrapP224(p), err
}

func (w p224Wrapper) ScalarBaseMult(scalar []byte) (WrappedPoint, error) {
p, err := w.point.ScalarBaseMult(scalar)
return wrapP224(p), err
}

type p256Wrapper struct {
point *P256Point
}

func wrapP256(point *P256Point) WrappedPoint {
return p256Wrapper{point: point}
}

func NewP256WrappedPoint() WrappedPoint {
return wrapP256(NewP256Point())
}

func NewP256WrappedGenerator() WrappedPoint {
return wrapP256(NewP256Generator())
}

func (w p256Wrapper) Bytes() []byte {
return w.point.Bytes()
}

func (w p256Wrapper) SetBytes(b []byte) (WrappedPoint, error) {
p, err := w.point.SetBytes(b)
return wrapP256(p), err
}

func (w p256Wrapper) Add(w1, w2 WrappedPoint) WrappedPoint {
return wrapP256(w.point.Add(w1.(p256Wrapper).point, w2.(p256Wrapper).point))
}

func (w p256Wrapper) Double(w1 WrappedPoint) WrappedPoint {
return wrapP256(w.point.Double(w1.(p256Wrapper).point))
}

func (w p256Wrapper) ScalarMult(w1 WrappedPoint, scalar []byte) (WrappedPoint, error) {
p, err := w.point.ScalarMult(w1.(p256Wrapper).point, scalar)
return wrapP256(p), err
}

func (w p256Wrapper) ScalarBaseMult(scalar []byte) (WrappedPoint, error) {
p, err := w.point.ScalarBaseMult(scalar)
return wrapP256(p), err
}

type p521Wrapper struct {
point *P521Point
}

func wrapP521(point *P521Point) WrappedPoint {
return p521Wrapper{point: point}
}

func NewP521WrappedPoint() WrappedPoint {
return wrapP521(NewP521Point())
}

func NewP521WrappedGenerator() WrappedPoint {
return wrapP521(NewP521Generator())
}

func (w p521Wrapper) Bytes() []byte {
return w.point.Bytes()
}

func (w p521Wrapper) SetBytes(b []byte) (WrappedPoint, error) {
p, err := w.point.SetBytes(b)
return wrapP521(p), err
}

func (w p521Wrapper) Add(w1, w2 WrappedPoint) WrappedPoint {
return wrapP521(w.point.Add(w1.(p521Wrapper).point, w2.(p521Wrapper).point))
}

func (w p521Wrapper) Double(w1 WrappedPoint) WrappedPoint {
return wrapP521(w.point.Double(w1.(p521Wrapper).point))
}

func (w p521Wrapper) ScalarMult(w1 WrappedPoint, scalar []byte) (WrappedPoint, error) {
p, err := w.point.ScalarMult(w1.(p521Wrapper).point, scalar)
return wrapP521(p), err
}

func (w p521Wrapper) ScalarBaseMult(scalar []byte) (WrappedPoint, error) {
p, err := w.point.ScalarBaseMult(scalar)
return wrapP521(p), err
}

type p384Wrapper struct {
point *P384Point
}

func wrapP384(point *P384Point) WrappedPoint {
return p384Wrapper{point: point}
}

func NewP384WrappedPoint() WrappedPoint {
return wrapP384(NewP384Point())
}

func NewP384WrappedGenerator() WrappedPoint {
return wrapP384(NewP384Generator())
}

func (w p384Wrapper) Bytes() []byte {
return w.point.Bytes()
}

func (w p384Wrapper) SetBytes(b []byte) (WrappedPoint, error) {
p, err := w.point.SetBytes(b)
return wrapP384(p), err
}

func (w p384Wrapper) Add(w1, w2 WrappedPoint) WrappedPoint {
return wrapP384(w.point.Add(w1.(p384Wrapper).point, w2.(p384Wrapper).point))
}

func (w p384Wrapper) Double(w1 WrappedPoint) WrappedPoint {
return wrapP384(w.point.Double(w1.(p384Wrapper).point))
}

func (w p384Wrapper) ScalarMult(w1 WrappedPoint, scalar []byte) (WrappedPoint, error) {
p, err := w.point.ScalarMult(w1.(p384Wrapper).point, scalar)
return wrapP384(p), err
}

func (w p384Wrapper) ScalarBaseMult(scalar []byte) (WrappedPoint, error) {
p, err := w.point.ScalarBaseMult(scalar)
return wrapP384(p), err
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.