from .libindy import do_call, create_cb
from typing import Optional
from ctypes import *
import logging
async def issuer_create_and_store_claim_def(wallet_handle: int,
issuer_did: str,
schema_json: str,
signature_type: Optional[str],
create_non_revoc: bool) -> str:
"""
Create keys (both primary and revocation) for the given schema
and signature type (currently only CL signature type is supported).
Store the keys together with signature type and schema in a secure wallet as a claim definition.
The claim definition in the wallet is identifying by a returned unique key.
:param wallet_handle: wallet handler (created by open_wallet).
:param issuer_did: a DID of the issuer signing claim_def transaction to the Ledger
:param schema_json: schema as a json
:param signature_type: signature type (optional). Currently only 'CL' is supported.
:param create_non_revoc: whether to request non-revocation claim.
:return: claim definition json containing information about signature type, schema and issuer's public key.
Unique number identifying the public key in the wallet
"""
logger = logging.getLogger(__name__)
logger.debug("issuer_create_and_store_claim_def: >>> wallet_handle: %r, issuer_did: %r, schema_json: %r,"
" signature_type: %r, create_non_revoc: %r",
wallet_handle,
issuer_did,
schema_json,
signature_type,
create_non_revoc)
if not hasattr(issuer_create_and_store_claim_def, "cb"):
logger.debug("issuer_create_and_store_claim_def: Creating callback")
issuer_create_and_store_claim_def.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))
c_wallet_handle = c_int32(wallet_handle)
c_issuer_did = c_char_p(issuer_did.encode('utf-8'))
c_schema_json = c_char_p(schema_json.encode('utf-8'))
c_signature_type = c_char_p(signature_type.encode('utf-8')) if signature_type is not None else None
c_create_non_revoc = c_bool(create_non_revoc)
claim_def_json = await do_call('indy_issuer_create_and_store_claim_def',
c_wallet_handle,
c_issuer_did,
c_schema_json,
c_signature_type,
c_create_non_revoc,
issuer_create_and_store_claim_def.cb)
res = claim_def_json.decode()
logger.debug("issuer_create_and_store_claim_def: <<< res: %r", res)
return res
async def issuer_create_and_store_revoc_reg(wallet_handle: int,
issuer_did: str,
schema_seq_no: int,
max_claim_num: int) -> str:
"""
Create a new revocation registry for the given claim definition.
Stores it in a secure wallet identifying by the returned key.
:param wallet_handle: wallet handler (created by open_wallet).
:param issuer_did: a DID of the issuer signing revoc_reg transaction to the Ledger
:param schema_seq_no: seq no of a schema transaction in Ledger
:param max_claim_num: maximum number of claims the new registry can process.
:return: Revoc registry json
"""
logger = logging.getLogger(__name__)
logger.debug("issuer_create_and_store_revoc_reg: >>> wallet_handle: %r, issuer_did: %r, schema_seq_no: %r,"
" max_claim_num: %r",
wallet_handle,
issuer_did,
schema_seq_no,
max_claim_num)
if not hasattr(issuer_create_and_store_revoc_reg, "cb"):
logger.debug("issuer_create_and_store_revoc_reg: Creating callback")
issuer_create_and_store_revoc_reg.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p, c_char_p))
c_wallet_handle = c_int32(wallet_handle)
c_issuer_did = c_char_p(issuer_did.encode('utf-8'))
c_schema_seq_no = c_int32(schema_seq_no)
c_max_claim_num = c_int32(max_claim_num)
revoc_reg_json = await do_call('indy_issuer_create_and_store_revoc_reg',
c_wallet_handle,
c_issuer_did,
c_schema_seq_no,
c_max_claim_num,
issuer_create_and_store_revoc_reg.cb)
res = revoc_reg_json.decode()
logger.debug("issuer_create_and_store_revoc_reg: <<< res: %r", res)
return res
async def issuer_create_claim(wallet_handle: int,
claim_req_json: str,
claim_json: str,
user_revoc_index: int) -> (str, str):
"""
Signs a given claim for the given user by a given key (claim ef).
The corresponding claim definition and revocation registry must be already created
an stored into the wallet.
:param wallet_handle: wallet handler (created by open_wallet).
:param claim_req_json: a claim request with a blinded secret
from the user (returned by prover_create_and_store_claim_req).
Also contains schema_seq_no and issuer_did
Example:
{
"blinded_ms" : <blinded_master_secret>,
"schema_seq_no" : <schema_seq_no>,
"issuer_did" : <issuer_did>
}
:param claim_json: a claim containing attribute values for each of requested attribute names.
Example:
{
"attr1" : ["value1", "value1_as_int"],
"attr2" : ["value2", "value2_as_int"]
}
:param user_revoc_index: index of a new user in the revocation registry
(optional, pass -1 if user_revoc_index is absentee; default one is used if not provided)
:return: Revocation registry update json with a newly issued claim
Claim json containing issued claim, issuer_did, and schema_seq_no
used for issuance
{
"claim": <see claim_json above>,
"signature": <signature>,
"issuer_did", string,
"schema_seq_no", string,
}
"""
logger = logging.getLogger(__name__)
logger.debug("issuer_create_claim: >>> wallet_handle: %r, claim_req_json: %r, claim_json: %r,"
" user_revoc_index: %r",
wallet_handle,
claim_req_json,
claim_json,
user_revoc_index)
if not hasattr(issuer_create_claim, "cb"):
logger.debug("issuer_create_claim: Creating callback")
issuer_create_claim.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p, c_char_p))
c_wallet_handle = c_int32(wallet_handle)
c_claim_req_json = c_char_p(claim_req_json.encode('utf-8'))
c_claim_json = c_char_p(claim_json.encode('utf-8'))
c_user_revoc_index = c_int32(user_revoc_index)
(revoc_reg_update_json, claim_json) = await do_call('indy_issuer_create_claim',
c_wallet_handle,
c_claim_req_json,
c_claim_json,
c_user_revoc_index,
issuer_create_claim.cb)
res = (revoc_reg_update_json.decode(), claim_json.decode())
logger.debug("issuer_create_claim: <<< res: %r", res)
return res
async def issuer_revoke_claim(wallet_handle: int,
issuer_did: str,
schema_seq_no: int,
user_revoc_index: int) -> str:
"""
Revokes a user identified by a revoc_id in a given revoc-registry.
The corre
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共13个文件
py:12个
pkg-info:1个
资源分类:Python库 所属语言:Python 资源全名:python3-indy-1.0.1-dev-247.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源详情
资源评论
资源推荐
收起资源包目录
python3-indy-1.0.1-dev-247.tar.gz (13个子文件)
python3-indy-1.0.1-dev-247
PKG-INFO 505B
setup.py 668B
indy
crypto.py 15KB
agent.py 4KB
pool.py 6KB
signus.py 28KB
wallet.py 6KB
libindy.py 3KB
__init__.py 33B
pairwise.py 6KB
anoncreds.py 32KB
error.py 4KB
ledger.py 20KB
共 13 条
- 1
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 444444444444
- DeepSeek-Coder-当大型语言模型遇见编程 - 代码智能的崛起(英文版)
- 一些基本的MATLAB画图程序示例.docx
- 傅里叶变换、滤波器和快速傅里叶变换(FFT)MATLAB仿真程序示例代码.docx
- 串口调试工具,用于模拟虚拟串口之间传输
- LN8322 SOP-8封装 30V半桥栅极驱动器 深圳市可芯电子有限公司.pdf
- DotNetBar布局
- 智能游戏设计案例介绍:利用Java和人工智能算法,设计智能游戏,实现智能对战、智能敌人等功能
- 智能垃圾分类系统案例介绍:结合Java和图像识别技术,设计智能垃圾分类系统,实现自动识别和分类垃圾
- 公共课平时成绩查询系统PHP
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0