当前位置:网站首页>Commission contract on BSV
Commission contract on BSV
2022-06-22 01:47:00 【Scrypt smart contract】
We are Alice Introduced a novel way , allow Bob Use her UTXO/ COINS , Without the need to Bob Provide her private key .Alice sign Bob The public key , So as to delegate the power of expenditure to Bob. Delegates have many use cases . for example , The user can authorize the app to spend on her behalf BSV. perhaps , The CFO wants the department head to release the funds allocated to the Department .

entrust
before , We developed a method , Give Way Alice Use her bitcoin private key in the transaction Sign any message . For delegated work , The message is just Bob The public key . By signing Bob The key of ,Alice Delegate the right to use her coins to Bob1.
When Alice When you want to delegate , She first locked the funds into the following contracts .
import "./oracle.scrypt";
contract Delegate {
PubKey owner;
public function delegate(Sig ownerSig, PubKey delegate, Sig delegateSig, PubKey derivedPubKey, PubKey X, int lambda, SigHashPreimage txPreimage) {
// ensure delegate's public key is signed by the owner
require(Oracle.verifyData(delegate, ownerSig, this.owner, derivedPubKey, X, lambda, txPreimage));
// delegate signs
require(checkSig(delegateSig, delegate));
}
}
She signed with her private key Bob The public key , That is to say 6 Yes ownerSig. She gave the partially signed transaction to Bob.Bob Put his signature ( The first 6 Yes delegateSig) Add to the transaction and broadcast it to spend locked in funds . The first 10 Line validation Bob The public key of is signed 2, And therefore get Alice Authorization of . The first 13 Line check Bob The signature of the .
Please note that , Delegation does not create any on chain transactions , This only happens in Bob The actual cost UTXO when .
If Alice Want to spend on your own UTXO, She can simply delegate to herself by signing her own public key . therefore , She can be in Bob Revoke the delegation before moving the coin .
Delegation and multi signature
And Alice and Bob Between the traditional 2-of-2 Multi signature compared to , The above contract can be entrusted to anyone ( for example , Entrusted to Charlie or Dave), Even in creating UTXO And then again . The trustee is undetermined , You can choose at will , Multi signature must know all the trustees in advance , You can't change it later . Delegation is more flexible .
Multiple commissions
stay Alice Entrusted to Bob after ,Bob Entrusted to Charlie,Charlie Re entrust to Dave, And so on .
The following modified contract allows multiple entrustments :
contract Delegate {
PubKey owner;
static const int N = 3;
public function delegateN(Sig[N] ownerSig, PubKey[N] delegate, Sig delegateSig, PubKey[N] derivedPubKey, PubKey[N] X, int[N] lambda, SigHashPreimage txPreimage) {
PubKey lastDelegate = this.owner;
loop (N) : i {
PubKey owner = i == 0 ? this.owner : delegate[i - 1];
// check if the next delegate is delegated by the current delegate
if (Oracle.verifyData(delegate[i], ownerSig[i], owner, derivedPubKey[i], X[i], lambda[i], txPreimage))
lastDelegate = delegate[i];
}
// last delegate signs
require(checkSig(delegateSig, lastDelegate));
}
}
Basically ,Alice signed Bob The public key ,Bob signed Charlie The public key ,…… The first 13 Line validation signature , To validate the delegate as before . Only the last representative is in 18 You can only spend coins by signing .
[1] Alternative signature algorithms can also be used , for example Rabin Signature .
[2] Be careful Oracle.verifyData() Use... Internally SIGHASH_NONE, therefore Bob You can add whatever output he wants .
边栏推荐
- After the counter is completed, you want to count the results whose string length is greater than 2
- Expenditure budget and adjustment records and use records output use progress construction process records
- Standing at the digital tuyere, how can tooling enterprises "fly"
- 联发科技 --联发科技简介++附上笔经面经
- C语言动态内存函数的应用
- ASEMI肖特基二极管1N5819参数,1N5819代换,1N5819货源
- redis实现分布式锁
- Pyechart drawing word cloud
- [tensorrt] video swing transformer deployment
- Is there a browser ranking suitable for Amazon cross-border E-commerce
猜你喜欢

华为云发布桌面IDE-CodeArts

【第 04 章 基于Hough变化的答题卡识别】

【第 07 章 基于主成分分析的人脸二维码识别MATLAB深度学习实战案例】

抓包工具:Fiddler,软件测试工程师必备技能

出现UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xe9 in position 0: ordinal not in range解决方法

LeetCode 5218. 个位数字为 K 的整数之和(枚举)

DAST 黑盒漏洞扫描器 第四篇:扫描性能

类和对象(下)

ASEMI肖特基二极管1N5819参数,1N5819代换,1N5819货源

Apache Doris real-time data analysis nanny level tutorial
随机推荐
php-admin部署-解决全部错误
【TensorRT】Video Swin-Transformer部署相关
阿里腾讯百度软件测试工程师推荐——软件测试模型之快速原型模型
Cache consistency of arm
【第 20 章 基于帧间差法进行视频目标检测--MATLAB软件深度学习应用】
【第 13 章 基于霍夫曼图像压缩重建--Matlab深度学习实战图像处理应用】
Curl requests at the server command line
Expenditure budget and adjustment records and use records output use progress construction process records
Standing at the digital tuyere, how can tooling enterprises "fly"
第 25 章 基于小波变换的数字水印技术
heidisql 插入数据老是出错,怎么办
Processing of the scenario of more or less delivery by suppliers in SAP mm import purchase business
带你区分几种并行
twenty-one
有没有亚马逊跨境电商适合用的浏览器排名
华为云发布桌面IDE-CodeArts
Farm Game
2022年Q1手机银行用户规模达6.5亿,加强ESG个人金融产品创新
How to read a paper
Is there a browser ranking suitable for Amazon cross-border E-commerce