---
title: negotiateSeeds
description: "调用此函数用于协商种子信息。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengcctrustzone/tee/kcal/kunpeng_kcal_16_0021.html
sourcePath: /source/zh/kunpengcctrustzone/tee/kcal/kunpeng_kcal_16_0021.html
indexId: 4ba0c417d947b414a4d138ac031f3fec9266b5630365f4f47c6ec4c269bfbc6364
---
# negotiateSeeds

调用此函数用于协商种子信息。

```
int negotiateSeeds (
DG_TeeCtx *dgTeeCtx
)
```

#### 参数


**表1 参数说明**

| 参数名 | 描述 | 取值范围 | 输入/输出 |
| --- | --- | --- | --- |
| dgTeeCtx | KCAL上下文信息 | 为initTeeCtx成功初始化的结果 | 输入 |


#### 返回值

- 成功：返回0。
- 失败：返回错误码。


#### 错误码


**表2 错误码**

| 错误码 | 错误码值 | 描述 | 特殊说明 |
| --- | --- | --- | --- |
| DG\_ERR\_MPC\_TEE\_INVALID\_PARAM | 4501 | 参数校验失败 | dgTeeCtx为NULL 通信接口未注册 节点信息不正确 |
| DG\_FAIL | 1 | 交换种子失败 | 生成随机数失败 交换种子失败 |


#### 依赖

- dgTeeCtx依赖  initTeeCtx
的成功初始化。
- 在交换种子前，需要先调用setTeeNodeInfos接口设置所有节点信息。
- 依赖的头文件为"data_guard_mpc.h"。


#### 示例

使用调用DG_InitArithmeticOpts成功后返回的aritOpts来调用negotiateSeeds接口。


```
#include  "data_guard_mpc.h"
/*调用negotiateSeeds前需先调用setTeeNodeInfos函数
dgTeeCtx是调用initTeeCtx成功初始化的上下文
*/
res = aritOpts.negotiateSeeds(dgTee);
```

运行结果：res为0。
