// CreateCompositeKey combines the list of attributes
//to form a composite key.
512156
func (stub *MockStub) CreateCompositeKey(objectType string, attributes []string) (string, error) {
	return createCompositeKey(objectType, attributes)
}
663638
func (client *Client) CreateKeyPair(args *CreateKeyPairArgs) (resp *CreateKeyPairResponse, err error) {
	response := CreateKeyPairResponse{}
	err = client.Invoke("CreateKeyPair", args, &response)
	if err != nil {
		return nil, err
	}
	return &response, err
}
1021259
func makeCompoundMessage(msgs [][]byte) *bytes.Buffer {
	// Create a local buffer
	buf := bytes.NewBuffer(nil)

	// Write out the type
	buf.WriteByte(uint8(compoundMsg))

	// Write out the number of message
	buf.WriteByte(uint8(len(msgs)))

	// Add the message lengths
	for _, m := range msgs {
		binary.Write(buf, binary.BigEndian, uint16(len(m)))
	}

	// Append the messages
	for _, m := range msgs {
		buf.Write(m)
	}

	return buf
}
1092188
func (c *Client) CreateKey(keyName, curveTypeString string, logger *logging.Logger) (crypto.PublicKey, error) {
	err := c.dial(logger)
	if err != nil {
		return crypto.PublicKey{}, err
	}
	if c.keyClient == nil {
		return crypto.PublicKey{}, fmt.Errorf("could not create key pair since no keys service is attached, " +
			"pass --keys flag")
	}
	curveType := crypto.CurveTypeEd25519
	if curveTypeString != "" {
		curveType, err = crypto.CurveTypeFromString(curveTypeString)
		if err != nil {
			return crypto.PublicKey{}, err
		}
	}
	address, err := c.keyClient.Generate(keyName, curveType)
	if err != nil {
		return crypto.PublicKey{}, err
	}
	return c.keyClient.PublicKey(address)
}
1329151
func (fk ForeignKeyElem) Create(d Dialect) (string, error) {
	// Compile the type
	ct, err := fk.typ.Create(d)
	if err != nil {
		return "", err
	}
	compiled := fmt.Sprintf(
		`"%s" %s REFERENCES %s("%s")`,
		fk.name,
		ct,
		fk.col.table.Name(),
		fk.col.Name(),
	)
	if fk.onDelete != nil {
		compiled += fmt.Sprintf(" ON DELETE %s", *fk.onDelete)
	}
	if fk.onUpdate != nil {
		compiled += fmt.Sprintf(" ON UPDATE %s", *fk.onUpdate)
	}
	return compiled, nil
}
302632
func (api UsersAPI) SaveKeyStoreKey(w http.ResponseWriter, r *http.Request) {
	username := mux.Vars(r)["username"]
	globalid := context.Get(r, "client_id").(string)

	body := keystore.KeyStoreKey{}

	if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
		log.Debug("Keystore key decoding failed: ", err)
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	// set/update the username and globalid values to those from the authentication
	body.Username = username
	body.Globalid = globalid
	// set the keys timestamp
	body.KeyData.TimeStamp = db.DateTime(time.Now())

	if !body.Validate() {
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	mgr := keystore.NewManager(r)

	// check if this user/organization already has a key under this label
	if _, err := mgr.GetKeyStoreKey(username, globalid, body.Label); err == nil {
		http.Error(w, http.StatusText(http.StatusConflict), http.StatusConflict)
		return
	}

	err := mgr.Create(&body)
	if err != nil {
		log.Error("error while saving keystore key: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	key, err := mgr.GetKeyStoreKey(username, globalid, body.Label)
	if err != nil {
		log.Error("error while retrieving keystore key: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	w.Header().Set("Content-type", "application/json")
	w.WriteHeader(http.StatusCreated)
	json.NewEncoder(w).Encode(key)
}
554563
func (c *CloudAPI) CreateKey(keyName, key string) (*cloudapi.Key, error) {
	if err := c.ProcessFunctionHook(c, keyName, key); err != nil {
		return nil, err
	}

	// check if key already exists or keyName already in use
	for _, k := range c.keys {
		if k.Name == keyName {
			return nil, fmt.Errorf("Key name %s already in use", keyName)
		}
		if k.Key == key {
			return nil, fmt.Errorf("Key %s already exists", key)
		}
	}

	newKey := cloudapi.Key{Name: keyName, Fingerprint: "", Key: key}
	c.keys = append(c.keys, newKey)

	return &newKey, nil
}
708365
func ConstructPartialCompositeHistoryKey(ns string, key string, endkey bool) []byte {
	var compositeKey []byte
	compositeKey = append(compositeKey, []byte(ns)...)
	compositeKey = append(compositeKey, CompositeKeySep...)
	compositeKey = append(compositeKey, []byte(key)...)
	compositeKey = append(compositeKey, CompositeKeySep...)
	if endkey {
		compositeKey = append(compositeKey, []byte{0xff}...)
	}
	return compositeKey
}
1370426
func CreateEphemeralKey(curve func() elliptic.Curve, pub *ecdsa.PublicKey) (*ecdsa.PrivateKey, []byte) {

	ephemeral, err := ecdsa.GenerateKey(curve(), rand.Reader)
	if err != nil {
		zap.L().Error("CreateEphemeralKey failed, returning empty array of bytes", zap.Error(err))
		return nil, []byte{}
	}

	ephPub := elliptic.Marshal(pub.Curve, ephemeral.PublicKey.X, ephemeral.PublicKey.Y)

	return ephemeral, ephPub

}
67643
func (c CryptoCommon) MakeRandomTLFEphemeralKeys() (
	kbfscrypto.TLFEphemeralPublicKey, kbfscrypto.TLFEphemeralPrivateKey,
	error) {
	return kbfscrypto.MakeRandomTLFEphemeralKeys()
}
1363283
func (p *PdfDictionaryObj) AddCompositeGlyphs(glyphArray *[]int, glyph int) {
	start := p.GetOffset(int(glyph))
	if start == p.GetOffset(int(glyph)+1) {
		return
	}

	offset := start
	ttfp := p.PtrToSubsetFontObj.GetTTFParser()
	fontData := ttfp.FontData()
	numContours, step := ReadShortFromByte(fontData, offset)
	offset += step
	if numContours >= 0 {
		return
	}

	offset += 8
	for {
		flags, step1 := ReadUShortFromByte(fontData, offset)
		offset += step1
		cGlyph, step2 := ReadUShortFromByte(fontData, offset)
		offset += step2
		//check cGlyph is contain in glyphArray?
		glyphContainsKey := false
		for _, g := range *glyphArray {
			if g == int(cGlyph) {
				glyphContainsKey = true
				break
			}
		}
		if !glyphContainsKey {
			*glyphArray = append(*glyphArray, int(cGlyph))
		}

		if (flags & MORE_COMPONENTS) == 0 {
			return
		}
		offsetAppend := 4
		if (flags & ARG_1_AND_2_ARE_WORDS) == 0 {
			offsetAppend = 2
		}
		if (flags & WE_HAVE_A_SCALE) != 0 {
			offsetAppend += 2
		} else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) != 0 {
			offsetAppend += 4
		}
		if (flags & WE_HAVE_A_TWO_BY_TWO) != 0 {
			offsetAppend += 8
		}
		offset += offsetAppend
	}
}
353766
func createSpentKey(txID string, index int) (string, error) {
	return createCompositeKey("tokenInput", []string{txID, strconv.Itoa(index)})
}
1343035
func (c *Client) CollaboratorCreate(appIdentity string, user string, options *CollaboratorCreateOpts) (*Collaborator, error) {
	params := struct {
		User   string `json:"user"`
		Silent *bool  `json:"silent,omitempty"`
	}{
		User: user,
	}
	if options != nil {
		params.Silent = options.Silent
	}
	var collaboratorRes Collaborator
	return &collaboratorRes, c.Post(&collaboratorRes, "/apps/"+appIdentity+"/collaborators", params)
}
1333339
func CreateChaincodeProposalWithTransient(typ common.HeaderType, chainID string, cis *peer.ChaincodeInvocationSpec, creator []byte, transientMap map[string][]byte) (*peer.Proposal, string, error) {
	// generate a random nonce
	nonce, err := crypto.GetRandomNonce()
	if err != nil {
		return nil, "", err
	}

	// compute txid
	txid, err := ComputeTxID(nonce, creator)
	if err != nil {
		return nil, "", err
	}

	return CreateChaincodeProposalWithTxIDNonceAndTransient(txid, typ, chainID, cis, nonce, creator, transientMap)
}
1126969
func NewKeyValueTree(k string, v interface{}, duplicates bool) KeyValueTree {
	return &keyValueTree{
		container: newNodeContainer(keyValue{k, v}, duplicates),
	}
}
1187884
func createOutputKey(txID string, index int) (string, error) {
	return createCompositeKey(tokenOutput, []string{txID, strconv.Itoa(index)})
}
1272188
func isCompositeType(s string) bool {
	if strings.HasPrefix(s, "message") ||
		strings.HasPrefix(s, "multipart") {
		return true
	}
	return false
}