id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c172900
{ o.SetCid(cid) return o }
c172901
if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
c172902
return codec, err } return NewCodec(words) }
c172903
err := LoadCodec(bank) if err != nil { panic(err) } return codec }
c172904
:= strings.Split(strings.TrimSpace(string(words)), "\n") return wordsAll, nil }
c172905
also generate this length, set maybeShorter if wordlenFromBytes(length-1) == numWords { maybeShorter = true } return }
c172906
// get the index, or an error rem, ok := c.bytes[word] if !ok { return -1, errors.Errorf("Unrecognized word: %s", word) } return rem, nil }
c172907
:= sha256.Sum256(bz) return hash[:Size] }
c172908
return subtle.ConstantTimeCompare(privKey[:], otherEd[:]) == 1 } else { return false } }
c172909
newBytes := Sha256(bz) newKey := new([64]byte) copy(newKey[:32], newBytes) ed25519.MakePublicKey(newKey) return PrivKeyEd25519(*newKey) }
c172910
value.Hash() sm.kvs = append(sm.kvs, cmn.KVPair{ Key: []byte(key), Value: vhash, }) }
c172911
path // cache the pubkey for later use pubKey, err := pk.getPubKey() if err != nil { return nil, err } pk.CachedPubKey = pubKey return &pk, err }
c172912
address if !pub.Equals(pk.CachedPubKey) { return fmt.Errorf("cached key does not match retrieved key") } return nil }
c172913
err != nil { return nil, err } sig, err := signLedgerSecp256k1(dev, pk.Path, msg) if err != nil { return nil, err } return sig, nil }
c172914
!= nil { return key, fmt.Errorf("please open Cosmos app on the Ledger device - error: %v", err) } return key, err }
c172915
:= other.(*PrivKeyLedgerSecp256k1); ok { return pk.CachedPubKey.Equals(ledger.CachedPubKey) } return false }
c172916
hash := item.Hash() hashes[i] = hash } return simpleHashFromHashes(hashes) }
c172917
leafHash, sp.Aunts) return computedHash != nil && bytes.Equal(computedHash, rootHash) }
c172918
if leftHash == nil { return nil } return SimpleHashFromTwoHashes(leftHash, innerHashes[len(innerHashes)-1]) } rightHash := computeHashFromAunts(index-numLeft, total-numLeft, leafHash, innerHashes[:len(innerHashes)-1]) if rightHash == nil { return nil } return SimpleHashFromTwoHashes(innerHashes[len(innerHashes)-1], rightHash) } }
c172919
:= DerivePrivateKeyForPath( HexDecode(mprivHex), HexDecode(chainHex), fmt.Sprintf("%v/%v", path, index), ) return HexEncode(privKeyBytes) }
c172920
true) return BTCAddrFromPubKeyBytes(pubKeyBytes) }
c172921
ecdsaPrivKey := &btcec.PrivateKey{ PublicKey: ecdsaPubKey, D: new(big.Int).SetBytes(privKeyBytes), } sigbytes, err := btcec.SignCompact(btcec.S256(), ecdsaPrivKey, CalcHash256(bytes), compress) if err != nil { panic(err) } return base64.StdEncoding.EncodeToString(sigbytes) }
c172922
PubKeyBytesFromPrivKeyBytes(secret, true) return HexEncode(pubKeyBytes), HexEncode(secret), HexEncode(chain) }
c172923
WIFFromPrivKeyBytes(HexDecode(privKey), compress) }
c172924
if i < 0 { panic(errors.New("index too large.")) } data, chainCode = DerivePublicKey(data, chainCode, uint32(i)) //printKeyInfo(nil, data, chainCode) } return data }
c172925
data = append(data, uint32ToBytes(index)...) data2, chainCode2 := I64(chainCode, data) x := addScalars(privKeyBytes, data2) return x, chainCode2 }
c172926
I64(chainCode, data) data2p := PubKeyBytesFromPrivKeyBytes(data2, true) return addPoints(pubKeyBytes, data2p), chainCode2 }
c172927
bp.X, bp.Y) sum := &btcec.PublicKey{ Curve: btcec.S256(), X: sumX, Y: sumY, } return sum.SerializeCompressed() }
c172928
btcec.S256().N).Bytes() x2 := [32]byte{} copy(x2[32-len(x):], x) return x2[:] }
c172929
:= hex.DecodeString(str) return b }
c172930
hmac.New(sha512.New, key) mac.Write(data) I := mac.Sum(nil) return I[:32], I[32:] }
c172931
checksum := CalcHash256(h160) b := append(h160, checksum[:4]...) return base58.Encode(b) }
c172932
CalcHash160(pubKeyBytes) _h160 := append([]byte{versionPrefix}, h160...) checksum = CalcHash256(_h160)[:4] return h160, checksum }
c172933
bytes = append(bytes, byte(1)) } checksum := CalcHash256(bytes) bytes = append(bytes, checksum[:4]...) return base58.Encode(bytes) }
c172934
Y: y, } if compress { return pub.SerializeCompressed() } return pub.SerializeUncompressed() }
c172935
/ 2 for left := 0; left <= mid; left++ { right := blen - left - 1 res[left] = buf[right] res[right] = buf[left] } return res }
c172936
err = ledger.FindLedger() } return device, err }
c172937
priv, err := crypto.NewPrivKeyLedgerSecp256k1(path) if err != nil { return nil, err } pub := priv.PubKey() return kb.writeLedgerKey(pub, path, name), nil }
c172938
return kb.writeOfflineKey(pub, name), nil }
c172939
of the actual secret with the type // appended. // ie [secret] = [type] + [secret] typ, secret := secret[0], secret[1:] algo := byteToSignAlgo(typ) priv, err := generate(algo, secret) if err != nil { return nil, err } // encrypt and persist key. public := kb.writeLocalKey(priv, name, passphrase) return public, nil }
c172940
for ; iter.Valid(); iter.Next() { info, err := readInfo(iter.Value()) if err != nil { return nil, err } res = append(res, info) } return res, nil }
c172941
:= kb.db.Get(infoKey(name)) return readInfo(bs) }
c172942
case offlineInfo: linfo := info.(offlineInfo) fmt.Printf("Bytes to sign:\n%s", msg) buf := bufio.NewReader(os.Stdin) fmt.Printf("\nEnter Amino-encoded signature:\n") // Will block until user inputs the signature signed, err := buf.ReadString('\n') if err != nil { return nil, nil, err } cdc.MustUnmarshalBinary([]byte(signed), sig) return sig, linfo.GetPubKey(), nil } sig, err = priv.Sign(msg) if err != nil { return nil, nil, err } pub = priv.PubKey() return sig, pub, nil }
c172943
:= readInfo(bz) if err != nil { return } return armorPubKeyBytes(info.GetPubKey().Bytes()), nil }
c172944
{ return } pubKey, err := crypto.PubKeyFromBytes(pubBytes) if err != nil { return } kb.writeOfflineKey(pubKey, name) return }
c172945
{ return err } kb.writeLocalKey(key, name, newpass) return nil default: return fmt.Errorf("Locally stored key required") } }
c172946
!= nil { PanicCrisis(err) } return b }
c172947
return nil, fmt.Errorf("Salt len must be %v", maxSaltSize) } p, err := newFromPassword(salt, password, cost) if err != nil { return nil, err } return p.Hash(), nil }
c172948
&hashed{otherHash, p.salt, p.cost, p.major, p.minor} if subtle.ConstantTimeCompare(p.Hash(), otherP.Hash()) == 1 { return nil } return ErrMismatchedHashAndPassword }
c172949
!= nil { return 0, err } return p.cost, nil }
c172950
if err != nil { return -1, err } err = checkCost(cost) if err != nil { return -1, err } p.cost = cost return 3, nil }
c172951
} } ps := printState{tparams: tparams} a.print(&ps) return ps.buf.String() }
c172952
= b ps.buf.WriteByte(b) }
c172953
= s[len(s)-1] } ps.buf.WriteString(s) }
c172954
is different. c++ if c > 1 { return } } } ps.printing = append(ps.printing, a) a.print(ps) ps.printing = ps.printing[:len(ps.printing)-1] }
c172955
ps.writeString(strings.Join(twq.Qualifiers, " ")) }
c172956
qual.(innerPrinter).printInner(ps) ps.inner = ps.inner[:len(ps.inner)-1] } }
c172957
== ps.inner[len(ps.inner)-1] { space = "" } ps.printOneInner(nil) } else { ps.writeString(" (") ps.printInner(false) ps.writeByte(')') } } ps.writeString(space) ps.writeByte('[') ps.print(at.Dimension) ps.writeByte(']') }
c172958
paren { ps.writeByte(')') } ps.writeByte('(') first := true for _, a := range ft.Args { if ps.isEmpty(a) { continue } if !first { ps.writeString(", ") } ps.print(a) first = false } ps.writeByte(')') ps.inner = save ps.printInner(false) }
c172959
default: paren = true } if paren { ps.writeByte('(') } ps.print(val) if paren { ps.writeByte(')') } }
c172960
*[]AST if prefixOnly { psave = &save } for len(ps.inner) > 0 { ps.printOneInner(psave) } return save }
c172961
ok { *save = append(*save, a) return } } if ip, ok := a.(innerPrinter); ok { ip.printInner(ps) } else { ps.print(a) } }
c172962
== 0 case *PackExpansion: return a.Pack != nil && ps.isEmpty(a.Base) default: return false } }
c172963
if err != nil { return name } return ret }
c172964
return "", err } return ASTToString(a, options...), nil }
c172965
options = append(options[:i], options[i+1:]...) } else { i++ } } a, err := globalCDtorName(name[len(prefix):], options...) return a, adjustErr(err, len(prefix)) } return nil, ErrNotMangledName }
c172966
a := st.encoding(params, notForLocalName) // Accept a clone suffix. if clones { for len(st.str) > 1 && st.str[0] == '.' && (isLower(st.str[1]) || st.str[1] == '_' || isDigit(st.str[1])) { a = st.cloneSuffix(a) } } if clones && len(st.str) > 0 { st.fail("unparsed characters at end of mangled name") } return a, nil }
c172967
new(state) *n = *st return n }
c172968
panic(demangleErr{err: err, off: st.off}) }
c172969
panic(demangleErr{err: err, off: st.off - dec}) }
c172970
st.str = st.str[add:] st.off += add }
c172971
panic("internal error") } st.advance(1) }
c172972
{ return fmt.Sprintf("%s at %d", de.err, de.off) }
c172973
ok { de.off += adj return de } return err }
c172974
*MethodWithQualifiers: return hasReturnType(a.Method) default: return false } }
c172975
return isCDtorConversion(a.Name) case *Constructor, *Destructor, *Cast: return true default: return false } }
c172976
:= st.str[:ln] final := "" st.advance(ln) for i := 0; i < len(str); i++ { if str[i] != '$' { final += string(str[i]) } else { if len(str) <= i+1 { st.failEarlier("java resource escape at end of string", 1) } i++ r, ok := map[byte]string{ 'S': "/", '_': ".", '$': "$", }[str[i]] if !ok { st.failEarlier("unrecognized java resource escape", ln-i-1) } final += r } } return &Special{Prefix: "java resource ", Val: &Name{Name: final}} }
c172977
{ if !m[qual] { q1 = append(q1, qual) m[qual] = true } } return q1 }
c172978
st.fail(fmt.Sprintf("cast template index out of range (%d >= %d)", a.Index, len(tmpl.Args))) } a.Template = tmpl return false default: for _, v := range seen { if v == a { return false } } seen = append(seen, a) return true } }) }
c172979
{ for _, a := range args { st.setTemplate(a, nil) } }
c172980
= append(exprs, e) if len(st.str) > 0 && st.str[0] == stop { st.advance(1) break } } return &ExprList{Exprs: exprs} }
c172981
== '_') { i++ } } for len(st.str) > i+1 && st.str[i] == '.' && isDigit(st.str[i+1]) { i += 2 for len(st.str) > i && isDigit(st.str[i]) { i++ } } suffix := st.str[:i] st.advance(i) return &Clone{Base: a, Suffix: suffix} }
c172982
seen = append(seen, a) return false } if r := a.Copy(simplifyOne, skip); r != nil { return r } return a }
c172983
*Name: return false case *TaggedName, *Operator, *BuiltinType, *FunctionParam: return false case *UnnamedType, *FixedType, *DefaultArg: return false } for _, v := range seen { if v == a { return false } } seen = append(seen, a) return true }) return ret }
c172984
{ out.WriteString(name) } else { if name[0] == '.' { out.WriteByte('.') } out.WriteString(result) } }
c172985
options = append(options, demangle.Verbose) } return options }
c172986
next error check with tests errors.Add([]string{}, DeserializationError, err.Error()) } else { form, parseErr := multipartReader.ReadForm(MaxMemory) if parseErr != nil { errors.Add([]string{}, DeserializationError, parseErr.Error()) } req.MultipartForm = form } } mapForm(formStruct, req.MultipartForm.Value, req.MultipartForm.File, errors) validateAndMap(formStruct, context, errors, ifacePtr...) } }
c172987
json.NewDecoder(req.Body).Decode(jsonStruct.Interface()) if err != nil && err != io.EOF { errors.Add([]string{}, DeserializationError, err.Error()) } } validateAndMap(jsonStruct, context, errors, ifacePtr...) } }
c172988
field.Type.Elem().Kind() == reflect.Struct) { errors = validateStruct(errors, fieldValue) } if strings.Index(field.Tag.Get("binding"), "required") > -1 { if reflect.DeepEqual(zero, fieldValue) { name := field.Name if j := field.Tag.Get("json"); j != "" { name = j } else if f := field.Tag.Get("form"); f != "" { name = f } errors.Add([]string{name}, RequiredError, "Required") } } } return errors }
c172989
resp.WriteHeader(http.StatusUnsupportedMediaType) } else { resp.WriteHeader(StatusUnprocessableEntity) } errOutput, _ := json.Marshal(errs) resp.Write(errOutput) return } }
c172990
:= locale.message.GetValue(section, format); err == nil { return value, true } } return "", false }
c172991
SetMessageWithDesc(lang, lang, filePath, appendFiles...) }
c172992
err := <-done; err != nil { return err } case <-stop: close(stopOrRestart) return <-done case err := <-done: if err != nil { return err } } } }
c172993
c.c.Noop(); err != nil { return err } case <-stop: return nil case <-c.c.LoggedOut(): return errors.New("disconnected while idling") } } }
c172994
== addr { continue } newAddrs = append(newAddrs, a) } newAddrs = append(newAddrs, addr) s.Addrs = newAddrs }
c172995
}, TestOnBorrow: func(c redis.Conn, t time.Time) error { _, err := c.Do("PING") return err }, } }
c172996
pool.Close() } } s.pools = nil }
c172997
(interface{}, error) { return queryForMaster(c, s.MasterName) }) if err != nil { return "", err } return res.(string), nil }
c172998
(interface{}, error) { return queryForSlaveAddrs(c, s.MasterName) }) if err != nil { return nil, err } return res.([]string), nil }
c172999
{ return net.JoinHostPort(s.ip, s.port) }