Claim Proof Bug——Aztec最大的45万美金bug bounty

1. 引言

近期,Aztec Labs通过其Immunefi bug bounty program,发出了其有史以来最大的bug bounty——45万美金,给白帽独立安全研究员lucash-dev,以感谢其所发现的Aztec Connect Claim Proof Bug,基本时间轴为:

  • 2023年9月12日,收到lucash-dev的submission——声称Aztec Connect在其核心ZK电路中有严重bug。
  • 2023年9月12日当天,Aztec团队验证了该submission的有效性,并采取了预防措施(进制公众访问该workflow以避免利用该漏洞)。
  • 2023年10月3日,完成补丁修复。
  • 2023年10月10日,给该白帽黑客支付了45万美金的bounty。

2. Claim Proof Bug详情

Aztec Connect为针对DeFi应用场景优化的专注隐私的zkRollup系统,使用ZKP来将其系统内的私有交易打包,支持用户相互私有转账,支持向L1合约私有转账。Aztec Connect的显著特性之一是:其DeFi交互,支持用户交换token或在协议内投资。

以多个用户想要对同一L1 DeFi协议投资为例,来说明Aztec Connect的工作原理:

  • 1)每个用户向mempool中提交一个DeFi interaction deposit proof。该proof会保持用户身份隐私,但是所投资目标协议和投资金额是公开的。
  • 2)sequencer groups试图与同一协议一起交互,一旦sequencer groups有足够的意图来高效切分L1开销,该系统会计算并提交一个rollup proof。
  • 3)一旦接收到rollup proof,该智能合约会代替用户,执行实际的投资或交换,接收所返还的tokens。
  • 4)在下一rollup,该sequencer完成特殊的claim proofs,给用户切分新收到的tokens。

lucash-dev所发现的bug在claim proof中,且仅可被sequencer利用(如,通过escape hatch)。

核心漏洞在于给特定用户的DeFi interaction计算final output(即,在某DeFi interaction之后能收到多少tokens),可被恶意sequencer欺骗。

若该程序以rust或C编写,则可简单地检查 r e s u l t = t o t a l _ o u t p u t ⋅ u s e r _ i n p u t t o t a l _ i n p u t result=total\_output\cdot \frac{user\_input}{total\_input} result=total_outputtotal_inputuser_input为整数即可。
但不幸的是,ZK电路基于的是有限域运算,而不是整数运算:

  • 因为ZK电路中的基础单位为有限域,需实现复杂的tricks来运行简单的整数运算。若熟悉有限域运算和ZK电路,则可跳过下一节“ZK电路背景知识”内容。

3. ZK电路背景知识

有限域模素数最小教程为:

  • 该有限域具有模 p p p,本场景下, p p p是素数(仅可被1和其自身整除)。如 p p p可为5但不可为6。
  • 该有限域内所有元素为从0到 p − 1 p-1 p1的整数。如 F 5 \mathbb{F}_5 F5的元素为 { 0 , 1 , 2 , 3 , 4 } \{0,1,2,3,4\} {0,1,2,3,4}
  • 可做加法运算。若2元素之和大于等于模 p p p,则将其结果减去该模,直到其满足如 3 + 4 = 2 m o d    5 3+4=2\mod 5 3+4=2mod5
  • 对某元素的负数,即为找到与其求和为0的元素,如 1 + 4 = 0 m o d    5 1+4=0\mod 5 1+4=0mod5
  • 乘法运算类似,如 3 ⋅ 3 = 4 m o d    5 3\cdot 3=4\mod 5 33=4mod5
  • 某元素倒数运算,是指找到与其乘积为1的元素,0没有倒数,其它元素都有相应的倒数。如 4 ⋅ 4 = 1 m o d    5 4\cdot 4=1\mod 5 44=1mod5
  • 减法运算,是指对其负数做加法运算。除法运算,是指对其倒数做乘法运算。

ZK电路使用有限域运算来包含connected gates。Aztec Connect采用TurboPlonk——可将其看成是对Plonk的扩展指令集。每个gate形式为:
q m ⋅ w l ⋅ w r + q 1 ⋅ w l + q 2 ⋅ w r + q 3 ⋅ w o + q c = 0 m o d    p q_m\cdot w_l\cdot w_r+q_1\cdot w_l+q_2\cdot w_r+q_3\cdot w_o+q_c=0\mod p qmwlwr+q1wl+q2wr+q3wo+qc=0modp
其中:

  • q m , q 1 , q 2 , q 3 , q c q_m,q_1,q_2,q_3,q_c qm,q1,q2,q3,qc为selectors。由电路编写者选择相应的selectors并定义该电路的逻辑。
  • w l , w r , w o w_l,w_r,w_o wl,wr,wo为witness值,可将其看成是某程序执行的中间状态。

该电路中包含很多如上形式的gates,各个 w w w值相互以多种方式连接,有些会连接到该电路的输入和输出:
在这里插入图片描述
y = 4 x 3 + 2 y=4x^3+2 y=4x3+2,可 以如下gates来表示:

  • 1) w l ⋅ w r − w o = 0 m o d    p w_l\cdot w_r-w_o=0\mod p wlwrwo=0modp
  • 2) 4 ⋅ w l ⋅ w r − w o + 2 = 0 m o d    p 4\cdot w_l\cdot w_r-w_o+2=0\mod p 4wlwrwo+2=0modp

将第一个gate的 w l w_l wl w r w_r wr与第二个gate的 w l w_l wl相连,以表示其对应相同的 x x x值,将第一个gate的 w o w_o wo与第二个gate的 w r w_r wr相连。然后第二个gate的 w o w_o wo y y y值。就很容易检查:

  • 1) x ⋅ x − x 2 = 0 m o d    p x\cdot x-x^2=0\mod p xxx2=0modp
  • 2) 4 ⋅ x ⋅ x 2 − y + 2 = 0 m o d    p 4\cdot x\cdot x^2-y+2=0\mod p 4xx2y+2=0modp

因此,这组具有合适wiring的gates就准确计算了所想表达的 y = 4 x 3 + 2 y=4x^3+2 y=4x3+2。有一些常用标准gates:

  • 1) w l ⋅ w r − w r = 0 m o d    p w_l\cdot w_r-w_r=0\mod p wlwrwr=0modp,其中通过wiring有 w l = w r w_l=w_r wl=wr:对应为Boolean gate x ⋅ ( x − 1 ) = 0 m o d    p x\cdot (x-1)=0\mod p x(x1)=0modp,以确保 x x x为0或者1值。
  • 2) w l + w r − w o = 0 m o d    p w_l+w_r-w_o=0\mod p wl+wrwo=0modp:为标准加法门。
  • 3) w l ⋅ w r − w o = 0 m o d    p w_l\cdot w_r-w_o=0\mod p wlwrwo=0modp:为标准乘法门。
  • 4) w l ⋅ w r − 1 = 0 m o d    p w_l\cdot w_r-1=0\mod p wlwr1=0modp:可确保 w l w_l wl为非零值。
  • 5) w l 1 ⋅ w r 1 − 1 = 0 w_{l_1}\cdot w_{r_1}-1=0 wl1wr11=0 w l 2 ⋅ w r 2 − w o 2 = 0 w_{l_2}\cdot w_{r_2}-w_{o_2}=0 wl2wr2wo2=0,其中 w r 1 , w r 2 w_{r_1},w_{r_2} wr1,wr2二者相连:表示 w o 2 = w l 2 w l 1 w_{o_2}=\frac{w_{l_2}}{w_{l_1}} wo2=wl1wl2
    • 该gate是电路核心思想的一个很好例子:你无需证明该计算,仅需提供其正确性的witness。
    • 为有限域除法运算。求倒数是很重的运算,但展示你找到了相应倒数就trivial多了,仅需要展示二者乘积为1。

3. 基于有限域的整数运算

Aztec Connect中需展示 u s e r _ o u t p u t = t o t a l _ o u t p u t ⋅ u s e r _ i n p u t t o t a l _ i n p u t user\_output=total\_output\cdot \frac{user\_input}{total\_input} user_output=total_outputtotal_inputuser_input为整数,但是是在电路中展示其为整数。

其中的问题之一就在于,整数除法情况下, u s e r _ o u t p u t user\_output user_output大多数情况下都是浮点数,即:
u s e r _ o u t p u t ⋅ t o t a l _ i n p u t ≤ t o t a l _ o u t p u t ⋅ u s e r _ i n p u t user\_output\cdot total\_input\leq total\_output\cdot user\_input user_outputtotal_inputtotal_outputuser_input

因此,需引入除法余数项:【claim ratio equation】
u s e r _ o u t p u t ⋅ t o t a l _ i n p u t + r e m a i n d e r = t o t a l _ o u t p u t ⋅ u s e r _ i n p u t user\_output\cdot total\_input + remainder = total\_output\cdot user\_input user_outputtotal_input+remainder=total_outputuser_input

从而支持满足该约束。但不幸的是,可改变 u s e r _ o u t p u t user\_output user_output为任意值,固定 t o t a l _ i n p u t , t o t a l _ o u p u t , u s e r _ i n p u t total\_input,total\_ouput,user\_input total_input,total_ouput,user_input值的情况下,只需要调整不同的 r e m a i n d e r remainder remainder 我们需确保该relation在整数层面是正确的,而不是在有限域元素层面。为此,需将其每个值拆分为68位limbs,并以school乘法逐元素的相同的方式检查整个relation的正确性。
12 ⋅ 12 = 11 ⋅ 13 + 1 12\cdot 12=11\cdot 13 +1 1212=1113+1

  • 首先检查低位 2 ⋅ 2 = 1 ⋅ 3 + 1 2\cdot 2=1\cdot 3+1 22=13+1
  • 若有进位,则将其加到10位数: 2 ⋅ 1 + 1 ⋅ 2 = 1 ⋅ 3 + 1 ⋅ 1 2\cdot 1+1\cdot 2=1\cdot 3+1\cdot 1 21+12=13+11
  • 检查百位数: 1 ⋅ 1 = 1 ⋅ 1 1\cdot 1=1\cdot 1 11=11

当做类似计算时,只需要在内存中计算各个位的乘积,因此不会溢出。用相同的方式来对该claim ratio equation实现整数检查,但limbs(digits)取值范围为 [ 0 , 2 68 − 1 ] [0,2^{68}-1] [0,2681],而不是 [ 0 , 9 ] [0,9] [0,9]。且每个数字包含4个这样的limbs。因此,有如下代码来实现该check:

	// takes a [204-208]-bit limb and splits it into a low 136-bit limb and a high 72-bit limb
    const auto split_out_carry_term = [&composer, &shift_2](const field_ct& limb) {
        const uint256_t limb_val = limb.get_value();

        const uint256_t lo_val = limb_val.slice(0, 68 * 2);
        const uint256_t hi_val = limb_val.slice(68 * 2, 256);

        const field_ct lo(witness_ct(&composer, lo_val));
        const field_ct hi(witness_ct(&composer, hi_val));

        lo.create_range_constraint(68 * 2);
        hi.create_range_constraint(72); // allow for 4 overflow bits

        limb.assert_equal(lo + (hi * shift_2));

        return std::array<field_ct, 2>{ lo, hi };
    };
	// Use schoolbook multiplication algorithm to multiply 2 4-limbed values together, then convert result into 4
    // 2-limb values (with limbs twice the size) that do not overlap
    const auto compute_product_limbs = [&split_out_carry_term, &shift_1](const std::array<field_ct, 4>& left,
                                                                         const std::array<field_ct, 4>& right,
                                                                         const std::array<field_ct, 4>& to_add,
                                                                         const bool use_residual = false) {
        // a = left[0] * right[0];
        const field_ct b = left[0].madd(right[1], left[1] * right[0]);
        const field_ct c = left[0].madd(right[2], left[1].madd(right[1], left[2] * right[0]));
        const field_ct d = left[0].madd(right[3], left[1].madd(right[2], left[2].madd(right[1], left[3] * right[0])));
        const field_ct e = left[1].madd(right[3], left[2].madd(right[2], left[3] * right[1]));
        const field_ct f = left[2].madd(right[3], left[3] * right[2]);
        // g = left[3] * right[3];

        if (use_residual) {
            const auto t0 =
                split_out_carry_term(to_add[0] + left[0].madd(right[0], (b * shift_1) + to_add[1] * shift_1));
            const auto r0 = t0[0];
            const auto t1 = split_out_carry_term(t0[1].add_two(c + to_add[2], to_add[3] * shift_1 + d * shift_1));
            const auto r1 = t1[0];
            const auto t2 = split_out_carry_term(t1[1].add_two(e, f * shift_1));
            const auto r2 = t2[0];
            const auto r3 = left[3].madd(right[3], t2[1]);
            return std::array<field_ct, 4>{ r0, r1, r2, r3 };
        }
        const auto t0 = split_out_carry_term(left[0].madd(right[0], (b * shift_1)));
        const auto r0 = t0[0];
        const auto t1 = split_out_carry_term(t0[1].add_two(c, d * shift_1));
        const auto r1 = t1[0];
        const auto t2 = split_out_carry_term(t1[1].add_two(e, f * shift_1));
        const auto r2 = t2[0];
        const auto r3 = left[3].madd(right[3], t2[1]);
        return std::array<field_ct, 4>{ r0, r1, r2, r3 };
    };

    const auto lhs = compute_product_limbs(left_1, right_1, { 0, 0, 0, 0 }, false);
    const auto rhs = compute_product_limbs(left_2, right_2, residual_limbs, true);

    bool_ct balanced(&composer, true);
    for (size_t i = 0; i < 4; ++i) {
        balanced = balanced && lhs[i] == rhs[i];
    }

    return balanced;

需将每个值切分为4个limbs来表示:
v a l u e = v a l u e 0 + v a l u e 1 ⋅ 2 68 + v a l u e 2 ⋅ 2 136 + v a l u e 3 ⋅ 2 204 m o d    p value=value_0+value_1\cdot 2^{68}+value_2\cdot 2^{136}+value_3\cdot 2^{204}\mod p value=value0+value1268+value22136+value32204modp
每个limb限定范围为68位,以确保分解正确(范围约束可很容易通过从boolean gaates组合witness来实现)。

该漏洞源自2个核心问题:

  • 1)该top limb被限定为68位
  • 2)对该remainder没有任何范围限制
	// Split a field_t element into 4 68-bit limbs
    const auto split_into_limbs = [&composer, &shift_1, &shift_2, &shift_3](const field_ct& input) {
        const uint256_t value = input.get_value();

        const uint256_t t0 = value.slice(0, 68);
        const uint256_t t1 = value.slice(68, 136);
        const uint256_t t2 = value.slice(136, 204);
        const uint256_t t3 = value.slice(204, 272);

        std::array<field_ct, 4> limbs{
            witness_ct(&composer, t0),
            witness_ct(&composer, t1),
            witness_ct(&composer, t2),
            witness_ct(&composer, t3),
        };

        field_ct limb_sum_1 = limbs[0].add_two(limbs[1] * shift_1, limbs[2] * shift_2);
        field_ct limb_sum_2 = input - (limbs[3] * shift_3);
        limb_sum_1.assert_equal(limb_sum_2);

        limbs[0].create_range_constraint(68);
        limbs[1].create_range_constraint(68);
        limbs[2].create_range_constraint(68);
        limbs[3].create_range_constraint(68); // The offending range constraint

        return limbs;
    };

若想通过分解,约束某值在 2 252 2^{252} 2252 2 272 2^{272} 2272范围内,若该range constraint为 2 252 2^{252} 2252,则可能丢失一一对应关系。现在对应每个原始值,其由 2 20 2^{20} 220个可能值。更具体来说,由于所有的运算都是对模 p p p的取模运算,可在分解中加上 p p p,在重构该值是额外的 p p p将会小时,因此,原始的整数层面的claim ratio equation将更新为:
( u s e r _ o u t p u t + a ⋅ p ) ⋅ ( t o t a l _ i n p u t + b ⋅ p ) + r e m a i n d e r + c ⋅ p = ( t o t a l _ o u t p u t + d ⋅ p ) ⋅ ( u s e r _ i n p u t + e ⋅ p ) (user\_output+a\cdot p)\cdot (total\_input+b\cdot p) + remainder + c\cdot p = (total\_output+d\cdot p)\cdot (user\_input+e\cdot p) (user_output+ap)(total_input+bp)+remainder+cp=(total_output+dp)(user_input+ep)

为简化,即假设 u s e r _ i n p u t = 1 user\_input=1 user_input=1,可设置 a = 0 , b = 0 , c = 0 , d = 1 , e = 0 a=0,b=0,c=0,d=1,e=0 a=0,b=0,c=0,d=1,e=0,然后获得equation:
u s e r _ o u t p u t ⋅ t o t a l _ i n p u t + r e m a i n d e r = t o t a l _ o u t p u t + p user\_output\cdot total\_input + remainder = total\_output + p user_outputtotal_input+remainder=total_output+p

可调整不同的 u s e r _ o u t p u t user\_output user_output值,只要 u s e r _ o u t p u t ⋅ t o t a l _ i n p u t > t o t a l _ o u t p u t user\_output\cdot total\_input > total\_output user_outputtotal_input>total_output u s e r _ o u t p u t ⋅ t o t a l _ i n p u t − t o t a l _ o u t p u t ≤ p user\_output\cdot total\_input - total\_output \leq p user_outputtotal_inputtotal_outputp,则将能计算出合适的remainder,由于remainder未被约束,且控制 u s e r _ i n p u t user\_input user_input给了偷TVL的机制。

4. 补丁

首要的问题是禁止对ratio equation中各个不同部分乘以 p p p的动作。如,可简单的对各个limbs做范围约束,使得原始值与切分后的值之间存在一一对应关系:

// Split a field_t element into 4 68-bit limbs
    const auto split_into_limbs = [&composer, &shift_1, &shift_2, &shift_3](const field_ct& input,
                                                                            const size_t MAX_INPUT_BITS) {
        const uint256_t value = input.get_value();

        constexpr size_t NUM_BITS_PER_LIMB = 68;

        ASSERT(MAX_INPUT_BITS <= MAX_NO_WRAP_INTEGER_BIT_LENGTH);
        ASSERT(MAX_INPUT_BITS > 0);

        const uint256_t t0 = value.slice(0, NUM_BITS_PER_LIMB);
        const uint256_t t1 = value.slice(NUM_BITS_PER_LIMB, 2 * NUM_BITS_PER_LIMB);
        const uint256_t t2 = value.slice(2 * NUM_BITS_PER_LIMB, 3 * NUM_BITS_PER_LIMB);
        const uint256_t t3 = value.slice(3 * NUM_BITS_PER_LIMB, 4 * NUM_BITS_PER_LIMB);

        std::array<field_ct, 4> limbs{
            witness_ct(&composer, t0),
            witness_ct(&composer, t1),
            witness_ct(&composer, t2),
            witness_ct(&composer, t3),
        };

        field_ct limb_sum_1 = limbs[0].add_two(limbs[1] * shift_1, limbs[2] * shift_2);
        field_ct limb_sum_2 = input - (limbs[3] * shift_3);
        limb_sum_1.assert_equal(limb_sum_2);

        // Since the modulus is a power of two minus one, we can simply range constrain each of the limbs
        size_t bits_left = MAX_INPUT_BITS;
        for (size_t i = 0; i < 4; i++) {
            // If we've run out of bits, enforce zero
            if (bits_left == 0) {
                limbs[i].assert_is_zero();
                // If there are not enough bits for a full lmb, reduce constraint
            } else if (bits_left < NUM_BITS_PER_LIMB) {
                limbs[i].create_range_constraint(bits_left);
                bits_left = 0;
            } else {
                // Just a regular limb
                limbs[i].create_range_constraint(NUM_BITS_PER_LIMB);
                bits_left -= NUM_BITS_PER_LIMB;
            }
        }

        return limbs;
    };

令一个问题是,若remainder未被约束,则即使约束了limbs,sequencer仍可能创建为depositor分配比其应得而少得多金额的proof。
观察 u s e r _ o u t p u t ⋅ t o t a l _ i n p u t + r e m a i n d e r = t o t a l _ o u t p u t ⋅ u s e r _ i n p u t user\_output\cdot total\_input + remainder = total\_output\cdot user\_input user_outputtotal_input+remainder=total_outputuser_input equation可知,可保持 t o t a l _ i n p u t total\_input total_input不变,通过增加 r e m a i n d e r remainder remainder来降低 u s e r _ o u t p u t user\_output user_output。因此,还需要对 r e m a i n d e r remainder remainder添加约束 r e m a i n d e r ∈ [ 0 , t o t a l i n p u t ) remainder\in[0,total_input) remainder[0,totalinput)

residual.create_range_constraint(notes::NOTE_VALUE_BIT_LENGTH, "ratio_check range constraint failure: residual");
    // We need to assert that residual < a2
    // i.e. a2 - residual > 0 => a2 - residual - 1 >= 0
(ratios.a2 - residual - 1)
        .normalize()
        .create_range_constraint(notes::NOTE_VALUE_BIT_LENGTH, "ratio_check range constraint failure: residual >= a2");

5. 结论

任何像Aztec Connect这样的大型项目,都需要额外注意安全实现,即使其代码以经过大量审计,该bug还是漏了。
如何在未来系统中尽可能减少类似bug的概率呢?未来Aztec Labs计划做如下流程改进,以避免类似bug:

  • 1)实现一种机制,使得所有ad-hoc原语实现均禁止。若需要做整数比较,则该代码必须走标准库,应标准库已重点检查过了。
  • 2)创建探测未约束值的自动工具,并让审计者重点关注这些未约束值和所派生值。

尽可能让人为错误影响最小化,对于构建强健系统来说至关重要,因此做冗余和自动化测试非常有价值。

参考资料

[1] 2023年10月hackmd Aztec Connect Claim Proof Bug
[2] 2023年10月Aztec Labs博客Aztec Labs Announces Our Largest-Ever Bug Bounty Of $450,000

Aztec系列博客

  • Aztec Hybrid Rollup:混合zkRollup,而非zkEVM
  • Proof Compression
  • Aztec Connect即将主网上线
  • Aztec connect bridge代码解析
  • Aztec 征集 Rollup Sequencer去中心化提案
  • Aztec的隐私抽象:在尊重EVM合约开发习惯的情况下实现智能合约隐私
  • 完全保密的以太坊交易:Aztec网络的隐私架构
  • Aztec.nr:Aztec的隐私智能合约框架——用Noir扩展智能合约功能
  • Aztec交易架构解析
  • 混合Rollup:探秘 Metis、Fraxchain、Aztec、Miden和Ola

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/107400.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

一文2000字从0到1用Jmeter全流程性能测试实战

项目背景&#xff1a; 我们的平台为全国某行业监控平台&#xff0c;经过3轮功能测试、接口测试后&#xff0c;98%的问题已经关闭&#xff0c;决定对省平台向全国平台上传数据的接口进行性能测试。 01、测试步骤 1、编写性能测试方案 由于我是刚进入此项目组不久&#xff0c…

【CSS】包含块

CSS规范中的包含块 包含块的内容&#xff1a; 元素的尺寸和位置&#xff0c;会受它的包含块所影响。 对于一些属性&#xff0c;例如 width, height, padding, margin&#xff0c;绝对定位元素的偏移值&#xff08;比如 position 被设置为 absolute 或 fixed&#xff09;&…

数据类型与运算符-java

数据类型与运算符 1、变量和类型 1.1、整形变量 基本语法格式&#xff1a; int 变量名 初始值;代码示例&#xff1a; int num 10 //定义一个整型变量 System.out.println(num);注意&#xff1a; 1&#xff09;java中&#xff0c;一个int变量占4个字节&#xff0c;和操作…

IDEA 2023.2.2 使用 Scala 编译报错 No scalac found to compile scala sources

一、问题 scala: No scalac found to compile scala sources 官网 Bug 链接 二、临时解决方案 Incrementality Type 先变成 IDEA 类型 Please go to Settings > Build, Execution, Deployment > Compiler > Scala Compiler and change the Incrementality type to …

【Idea】idea启动同一程序不同端口

前言 在idea中配置两个不同端口&#xff0c;同时运行两个相同的主程序。 更多端口配置同理 idea版本:2022.2.3 1.在service中复制一个进程,指定不同端口 右键打开点击 copy Configuration 2.点击Modify option 2. 选择VM option(用于指定新的端口) 页面就会出现下面的指定…

lunar-1.5.jar

公历农历转换包 https://mvnrepository.com/artifact/com.github.heqiao2010/lunar <!-- https://mvnrepository.com/artifact/com.github.heqiao2010/lunar --> <dependency> <groupId>com.github.heqiao2010</groupId> <artifactId>l…

【C++】详解map和set基本接口及使用

文章目录 一、关联式容器与键值对1.1关联式容器&#xff08;之前学的都是序列容器&#xff09;1.2键值对pairmake_pair函数&#xff08;map在插入的时候会很方便&#xff09; 1.3树形结构的关联式容器 二、set2.1set的基本介绍2.1默认构造、迭代器区间构造、拷贝构造&#xff0…

A星算法(A* A Star algorithm)原理以及代码实例,超详细,超简单,大白话谁都能看懂

本文以这篇博主的文章为基础【精选】A*算法&#xff08;超级详细讲解&#xff0c;附有举例的详细手写步骤&#xff09;-CSDN博客 这篇文章的博主做了一个UI界面&#xff0c;但我感觉&#xff0c;这样对新手关注算法和代码本身反而不利&#xff0c;会被界面的代码所干扰。所以笔…

Linux - 进程的优先级 和 如何使用优先级调度进程

理解linux 当中如何做到 把一个PCB 放到多个 数据结构当中 在Linux 当中&#xff0c;一个进程的 PCB 不会仅仅值存在一个 数据结构当中&#xff0c;他既可以在 某一个队列当中&#xff0c;又可以在 一个 多叉树当中。 队列比如 cpu 的 运行队列&#xff0c;键盘的阻塞队列等等…

git教程(1)---本地仓库操作

git教程 git安装-Centos基本操作git initgit config工作区和版本库工作区暂存区/索引版本库 添加文件---场景一git statusgit log查看.git目录结构 添加文件---场景二修改文件版本回退撤销修改场景一只有工作区有code工作区和暂存区有code所有区域都有code并且没有push到远程仓…

实体店做商城小程序如何

互联网电商深入各个行业&#xff0c;传统线下店商家无论产品销售还是服务业&#xff0c;仅靠以往的经营模式&#xff0c;很难拓展到客户&#xff0c;老客流失严重&#xff0c;同时渠道单一&#xff0c;无法实现外地客户购物及线上客户赋能等。 入驻第三方平台有优势但也有不足…

大数据采集技术与预处理学习一:大数据概念、数据预处理、网络数据采集

目录 大数据概念&#xff1a; 1.数据采集过程中会采集哪些类型的数据&#xff1f; 2.非结构化数据采集的特点是什么&#xff1f; 3.请阐述传统的数据采集与大数据采集的区别&#xff1f; ​​​​​​​ ​​​​​​​4.大数据采集的数据源有哪些&#xff1f;针对不同的数…

理解V3中的proxy和reflect

现有如下面试题 结合GeexCode和Gpt // 这个函数名为onWatch&#xff0c;接受三个参数obj、setBind和getlogger。 // obj是需要进行监视的对象。 // setBind是一个回调函数&#xff0c;用于在设置属性时进行绑定操作。 // getlogger是一个回调函数&#xff0c;用于在获取属性时…

C# 压缩图片

.net下跨平台图像处理 https://github.com/mono/SkiaSharp 安装包 skiasharp 效果 代码 ImageCompression.cs using SkiaSharp;namespace ImageCompressStu01 {/// <summary>/// 图片压缩/// </summary>public class ImageCompression{/// <summary>/…

在spring boot+vue项目中@CrossOrigin 配置了允许跨域但是依然报错跨域,解决跨域请求的一次残酷经历

首先&#xff0c;说一下我们的项目情况&#xff0c;我们项目中后端有一个过滤器&#xff0c;如果必须要登录的接口路径会被拦下来检查&#xff0c;前端要传一个token&#xff0c;然后后端根据这个token来判断redis中这个用户是否已经登录。 if (request.getMethod().equals(&qu…

深入了解 Elasticsearch 8.1 中的 Script 使用

一、什么是 Elasticsearch Script&#xff1f; Elasticsearch 中的 Script 是一种灵活的方式&#xff0c;允许用户在查询、聚合和更新文档时执行自定义的脚本。这些脚本可以用来动态计算字段值、修改查询行为、执行复杂的条件逻辑等等。 二、支持的脚本语言有哪些 支持多种脚本…

数据分享 I 地级市人口和土地使用面积基本情况

数据地址&#xff1a; 地级市人口和土地使用面积基本情况https://www.xcitybox.com/datamarketview/#/Productpage?id394 基本信息. 数据名称: 地级市人口和土地使用面积基本情况 数据格式: ShpExcel 数据时间: 2021年 数据几何类型: 面 数据坐标系: WGS84坐标系 数据…

oracle19c配置驱动

1.遇到的问题 下载jar包 https://www.oracle.com/database/technologies/appdev/jdbc-ucp-19c-downloads.html 执行命令 mvn install:install-file -DgroupIdcom.oracle -DartifactIdojdbc19 -Dversion19.3.0.0 -Dpackagingjar -Dfileojdbc8.jar2.配置驱动 # 数据源配置 data…

lua-web-utils和proxy设置示例

以下是一个使用lua-web-utils和proxy的下载器程序&#xff1a; -- 首先安装lua-web-utils库 local lwu require "lwu" ​ -- 获取服务器 local function get_proxy()local proxy_url "duoipget_proxy"local resp, code, headers, err lwu.fetch(proxy_…

基于jquery+html开发的json格式校验工具

json简介 JSON是一种轻量级的数据交换格式。 易于人阅读和编写。同时也易于机器解析和生成。 它基于JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999的一个子集。 JSON采用完全独立于语言的文本格式&#xff0c;但是也使用了类似于C语言家族…
最新文章