Fix misspelling according to goreportcard result (#282)

pull/2757/head
Loyalsoldier 2020-10-08 08:53:15 +08:00 committed by GitHub
parent 425b4b497d
commit 454528353d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 25 additions and 24 deletions

View File

@ -209,7 +209,7 @@ func New(ctx context.Context, config *Config) (*Server, error) {
ruleIter = 0 ruleIter = 0
ruleCurr++ ruleCurr++
} }
} else { // No original rule, generate one according to current domain matcher (majorly for compability with tests) } else { // No original rule, generate one according to current domain matcher (majorly for compatibility with tests)
info.domainRuleIdx = uint16(len(rules)) info.domainRuleIdx = uint16(len(rules))
rules = append(rules, matcher.String()) rules = append(rules, matcher.String())
} }

View File

@ -382,11 +382,11 @@ func TestStatsChannelConcurrency(t *testing.T) {
errCh <- fmt.Sprint("unexpected block from receiving data: ", 1) errCh <- fmt.Sprint("unexpected block from receiving data: ", 1)
} }
// Test `b` is not closed but cannot receive data 2: // Test `b` is not closed but cannot receive data 2:
// Becuase in a new round of messaging, `b` has been unsubscribed. // Because in a new round of messaging, `b` has been unsubscribed.
select { select {
case v, ok := <-b: case v, ok := <-b:
if ok { if ok {
errCh <- fmt.Sprint("unexpected receving: ", v) errCh <- fmt.Sprint("unexpected receiving: ", v)
} else { } else {
errCh <- fmt.Sprint("unexpected closing of channel") errCh <- fmt.Sprint("unexpected closing of channel")
} }

View File

@ -6,7 +6,7 @@ package generic
// var GenericType generic.Type // var GenericType generic.Type
type Type interface{} type Type interface{}
// Number is the placehoder type that indiccates a generic numerical value. // Number is the placeholder type that indiccates a generic numerical value.
// When genny is executed, variables of this type will be replaced with // When genny is executed, variables of this type will be replaced with
// references to the specific types. // references to the specific types.
// var GenericType generic.Number // var GenericType generic.Number

View File

@ -16,7 +16,7 @@ func Addc64(cin, a, b uint64) (ret, cout uint64) {
return return
} }
// Substracts 2 64bit digits in constant time. // Subtracts 2 64bit digits in constant time.
// Returns result and borrow (1 or 0) // Returns result and borrow (1 or 0)
func Subc64(bIn, a, b uint64) (ret, bOut uint64) { func Subc64(bIn, a, b uint64) (ret, bOut uint64) {
var tmp1 = a - b var tmp1 = a - b

View File

@ -429,7 +429,7 @@ func (point *ProjectivePoint) ToAffine(c *CurveOperations) *Fp2Element {
// Cleans data in fp // Cleans data in fp
func (fp *Fp2Element) Zeroize() { func (fp *Fp2Element) Zeroize() {
// Zeroizing in 2 seperated loops tells compiler to // Zeroizing in 2 separated loops tells compiler to
// use fast runtime.memclr() // use fast runtime.memclr()
for i := range fp.A { for i := range fp.A {
fp.A[i] = 0 fp.A[i] = 0

View File

@ -70,7 +70,7 @@ func fp503MontgomeryReduce(z *FpElement, x *FpElementX2) {
var uv Uint128 var uv Uint128
var count int var count int
count = 3 // number of 0 digits in the least significat part of p503 + 1 count = 3 // number of 0 digits in the least significant part of p503 + 1
for i := 0; i < NumWords; i++ { for i := 0; i < NumWords; i++ {
for j := 0; j < i; j++ { for j := 0; j < i; j++ {

View File

@ -219,7 +219,7 @@ func (dest *primeFieldElement) Pow2k(x *primeFieldElement, k uint8) *primeFieldE
// //
// Returns dest to allow chaining operations. // Returns dest to allow chaining operations.
func (dest *primeFieldElement) P34(x *primeFieldElement) *primeFieldElement { func (dest *primeFieldElement) P34(x *primeFieldElement) *primeFieldElement {
// Sliding-window strategy computed with etc/scripts/sliding_window_strat_calc.py // Sliding-window strategy computed with etc/scripts/sliding_window_start_calc.py
// //
// This performs sum(powStrategy) + 1 squarings and len(lookup) + len(mulStrategy) // This performs sum(powStrategy) + 1 squarings and len(lookup) + len(mulStrategy)
// multiplications. // multiplications.

View File

@ -69,7 +69,7 @@ func fp751MontgomeryReduce(z *FpElement, x *FpElementX2) {
var uv Uint128 var uv Uint128
var count int var count int
count = 5 // number of 0 digits in the least significat part of p751 + 1 count = 5 // number of 0 digits in the least significant part of p751 + 1
for i := 0; i < NumWords; i++ { for i := 0; i < NumWords; i++ {
for j := 0; j < i; j++ { for j := 0; j < i; j++ {

View File

@ -3,6 +3,7 @@ package sidh
import ( import (
"errors" "errors"
"io" "io"
. "v2ray.com/core/external/github.com/cloudflare/sidh/internal/isogeny" . "v2ray.com/core/external/github.com/cloudflare/sidh/internal/isogeny"
) )
@ -173,7 +174,7 @@ func (prv *PrivateKey) Generate(rand io.Reader) error {
// Private key generation takes advantage of the fact that keyspace for secret // Private key generation takes advantage of the fact that keyspace for secret
// key is (0, 2^x - 1), for some possitivite value of 'x' (see SIKE, 1.3.8). // key is (0, 2^x - 1), for some possitivite value of 'x' (see SIKE, 1.3.8).
// It means that all bytes in the secret key, but the last one, can take any // It means that all bytes in the secret key, but the last one, can take any
// value between <0x00,0xFF>. Similarily for the last byte, but generation // value between <0x00,0xFF>. Similarly for the last byte, but generation
// needs to chop off some bits, to make sure generated value is an element of // needs to chop off some bits, to make sure generated value is an element of
// a key-space. // a key-space.
_, err = io.ReadFull(rand, prv.Scalar) _, err = io.ReadFull(rand, prv.Scalar)
@ -182,7 +183,7 @@ func (prv *PrivateKey) Generate(rand io.Reader) error {
} }
prv.Scalar[len(prv.Scalar)-1] &= (1 << (dp.SecretBitLen % 8)) - 1 prv.Scalar[len(prv.Scalar)-1] &= (1 << (dp.SecretBitLen % 8)) - 1
// Make sure scalar is SecretBitLen long. SIKE spec says that key // Make sure scalar is SecretBitLen long. SIKE spec says that key
// space starts from 0, but I'm not confortable with having low // space starts from 0, but I'm not comfortable with having low
// value scalars used for private keys. It is still secrure as per // value scalars used for private keys. It is still secrure as per
// table 5.1 in [SIKE]. // table 5.1 in [SIKE].
prv.Scalar[len(prv.Scalar)-1] |= 1 << ((dp.SecretBitLen % 8) - 1) prv.Scalar[len(prv.Scalar)-1] |= 1 << ((dp.SecretBitLen % 8) - 1)

View File

@ -18,15 +18,15 @@ func traverseTreePublicKeyA(curve *ProjectiveCurveParameters, xR, phiP, phiQ, ph
cparam := op.CalcCurveParamsEquiv4(curve) cparam := op.CalcCurveParamsEquiv4(curve)
phi := Newisogeny4(op.Params.Op) phi := Newisogeny4(op.Params.Op)
strat := pub.params.A.IsogenyStrategy strategy := pub.params.A.IsogenyStrategy
stratSz := len(strat) stratSz := len(strategy)
for j := 1; j <= stratSz; j++ { for j := 1; j <= stratSz; j++ {
for i <= stratSz-j { for i <= stratSz-j {
points = append(points, *xR) points = append(points, *xR)
indices = append(indices, i) indices = append(indices, i)
k := strat[sidx] k := strategy[sidx]
sidx++ sidx++
op.Pow2k(xR, &cparam, 2*k) op.Pow2k(xR, &cparam, 2*k)
i += int(k) i += int(k)
@ -57,15 +57,15 @@ func traverseTreeSharedKeyA(curve *ProjectiveCurveParameters, xR *ProjectivePoin
cparam := op.CalcCurveParamsEquiv4(curve) cparam := op.CalcCurveParamsEquiv4(curve)
phi := Newisogeny4(op.Params.Op) phi := Newisogeny4(op.Params.Op)
strat := pub.params.A.IsogenyStrategy strategy := pub.params.A.IsogenyStrategy
stratSz := len(strat) stratSz := len(strategy)
for j := 1; j <= stratSz; j++ { for j := 1; j <= stratSz; j++ {
for i <= stratSz-j { for i <= stratSz-j {
points = append(points, *xR) points = append(points, *xR)
indices = append(indices, i) indices = append(indices, i)
k := strat[sidx] k := strategy[sidx]
sidx++ sidx++
op.Pow2k(xR, &cparam, 2*k) op.Pow2k(xR, &cparam, 2*k)
i += int(k) i += int(k)
@ -92,15 +92,15 @@ func traverseTreePublicKeyB(curve *ProjectiveCurveParameters, xR, phiP, phiQ, ph
cparam := op.CalcCurveParamsEquiv3(curve) cparam := op.CalcCurveParamsEquiv3(curve)
phi := Newisogeny3(op.Params.Op) phi := Newisogeny3(op.Params.Op)
strat := pub.params.B.IsogenyStrategy strategy := pub.params.B.IsogenyStrategy
stratSz := len(strat) stratSz := len(strategy)
for j := 1; j <= stratSz; j++ { for j := 1; j <= stratSz; j++ {
for i <= stratSz-j { for i <= stratSz-j {
points = append(points, *xR) points = append(points, *xR)
indices = append(indices, i) indices = append(indices, i)
k := strat[sidx] k := strategy[sidx]
sidx++ sidx++
op.Pow3k(xR, &cparam, k) op.Pow3k(xR, &cparam, k)
i += int(k) i += int(k)
@ -131,15 +131,15 @@ func traverseTreeSharedKeyB(curve *ProjectiveCurveParameters, xR *ProjectivePoin
cparam := op.CalcCurveParamsEquiv3(curve) cparam := op.CalcCurveParamsEquiv3(curve)
phi := Newisogeny3(op.Params.Op) phi := Newisogeny3(op.Params.Op)
strat := pub.params.B.IsogenyStrategy strategy := pub.params.B.IsogenyStrategy
stratSz := len(strat) stratSz := len(strategy)
for j := 1; j <= stratSz; j++ { for j := 1; j <= stratSz; j++ {
for i <= stratSz-j { for i <= stratSz-j {
points = append(points, *xR) points = append(points, *xR)
indices = append(indices, i) indices = append(indices, i)
k := strat[sidx] k := strategy[sidx]
sidx++ sidx++
op.Pow3k(xR, &cparam, k) op.Pow3k(xR, &cparam, k)
i += int(k) i += int(k)

View File

@ -1019,7 +1019,7 @@ func (hs *clientHandshakeState) doTLS13Handshake() error {
serverHandshakeSecret := hs.keySchedule.deriveSecret(secretHandshakeServer) serverHandshakeSecret := hs.keySchedule.deriveSecret(secretHandshakeServer)
c.in.exportKey(hs.keySchedule.suite, serverHandshakeSecret) c.in.exportKey(hs.keySchedule.suite, serverHandshakeSecret)
// Already the sender key yet, when using an alternative record layer. // Already the sender key yet, when using an alternative record layer.
// QUIC needs the handshake write key in order to acknowlege Handshake packets. // QUIC needs the handshake write key in order to acknowledge Handshake packets.
c.out.exportKey(hs.keySchedule.suite, clientHandshakeSecret) c.out.exportKey(hs.keySchedule.suite, clientHandshakeSecret)
// Do not change the sender key yet, the server must authenticate first. // Do not change the sender key yet, the server must authenticate first.
c.in.setKey(c.vers, hs.keySchedule.suite, serverHandshakeSecret) c.in.setKey(c.vers, hs.keySchedule.suite, serverHandshakeSecret)