bitcoind – How to generate valid BTC address to withdraw coins to

Your bitcoin client is generating a P2WPKH (bech32 encoded) address, which is a newer address format which has some benefits compared to legacy formats. The address is valid, but for whatever reason, the exchange mentioned has not upgraded it’s code to recognize and send to this address type yet.

The fix is easy: you just need to tell bitcoin-core to generate a legacy address. You can use the following command:

$ bitcoin-cli getnewaddress "(address_label)" "legacy"

You can substitute your own label in for the (address_label), this is just for local book-keeping purposes, it can also just be left blank if you’d like:

$ bitcoin-cli getnewaddress "" "legacy"

SSL Certificate – the private key you’ve selected does not appear to be valid

I have a generated SSL certificate with Goddady and I uploaded the certificate and private key into Google Cloud and I get this message “the private key you’ve selected does not appear to be valid”. I ran the following command “openssl rsa -in private.key -out private_rsa.key” and I get this message “Can’t open private.key for reading, No such file or directory
139828091827392:error:02001002:system library:fopen:No such file or directory:../crypto/bio/bss_file.c:69:fopen(‘private.key’,’r’)
139828091827392:error:2006D080:BIO routines:BIO_new_file:no such file:../crypto/bio/bss_file.c:76:
unable to load Private Key”
Any suggestions to get this working?

transactions – How can be proven that a signature is valid with it’s public key

If someone wants to make a transaction, they need to sign the transaction data with their private key. For example Sign(transactionData, privateKey) creates the signature. What is exactly this Sign function and what happens inside this function? And how can be verified that a signature is valid with a public key? For example Verify(signature, publicKey), what happens inside this function?

python – Leetcode valid sudoku

Link here

I’ll include a solution in Python and C++ and you can review one. I’m mostly interested in reviewing the C++ code which is a thing I recently started learning; those who don’t know C++ can review the Python code. Both solutions share similar logic, so the review will apply to any.


Problem statement

Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:

  • Each row must contain the digits 1-9 without repetition. Each column
  • must contain the digits 1-9 without repetition. Each of the nine 3 x
  • 3 sub-boxes of the grid must contain the digits 1-9 without
    repetition.

Note:

A Sudoku board (partially filled) could be valid but is not necessarily solvable.
Only the filled cells need to be validated according to the mentioned rules.

Example 1:

Input: board = 
(("5","3",".",".","7",".",".",".",".")
,("6",".",".","1","9","5",".",".",".")
,(".","9","8",".",".",".",".","6",".")
,("8",".",".",".","6",".",".",".","3")
,("4",".",".","8",".","3",".",".","1")
,("7",".",".",".","2",".",".",".","6")
,(".","6",".",".",".",".","2","8",".")
,(".",".",".","4","1","9",".",".","5")
,(".",".",".",".","8",".",".","7","9"))
Output: true

Example 2:

Input: board = 
(("8","3",".",".","7",".",".",".",".")
,("6",".",".","1","9","5",".",".",".")
,(".","9","8",".",".",".",".","6",".")
,("8",".",".",".","6",".",".",".","3")
,("4",".",".","8",".","3",".",".","1")
,("7",".",".",".","2",".",".",".","6")
,(".","6",".",".",".",".","2","8",".")
,(".",".",".","4","1","9",".",".","5")
,(".",".",".",".","8",".",".","7","9"))
Output: false
Explanation: Same as Example 1, except with the 5 in the top left corner being modified to 8. Since there are two 8's in the top left 3x3 sub-box, it is invalid.

valid_sudoku.py

def is_valid(board, empty_value='.', b_size=3):
    seen = set()
    size = b_size * b_size
    for row in range(size):
        for col in range(size):
            if (value := board(row)(col)) == empty_value:
                continue
            r = f'0{row}{value}'
            c = f'1{col}{value}'
            b = f'2{row // b_size}{col // b_size}{value}'
            if r in seen or c in seen or b in seen:
                return False
            seen.update({r, c, b})
    return True


if __name__ == '__main__':
    g = (
        ("5", "3", ".", ".", "7", "5", ".", ".", "."),
        ("6", ".", ".", "1", "9", "5", ".", ".", "."),
        (".", "9", "8", ".", ".", ".", ".", "6", "."),
        ("8", ".", ".", ".", "6", ".", ".", ".", "3"),
        ("4", ".", ".", "8", ".", "3", ".", ".", "1"),
        ("7", ".", ".", ".", "2", ".", ".", ".", "6"),
        (".", "6", ".", ".", ".", ".", "2", "8", "."),
        (".", ".", ".", "4", "1", "9", ".", ".", "5"),
        (".", ".", ".", ".", "8", ".", ".", "7", "9"),
    )
    print(is_valid(g))

Stats:

Runtime: 92 ms, faster than 81.70% of Python3 online submissions for Valid Sudoku.
Memory Usage: 14.1 MB, less than 73.95% of Python3 online submissions for Valid Sudoku.

Here’s an alternative solution using numpy, it’s shorter and more readable but slower:

import numpy as np


def is_valid(board, size=3, empty_value='.'):
    board = np.array(board)
    blocks = board.reshape(4 * (size)).transpose(0, 2, 1, 3).reshape(2 * (size * size))
    for grid in (board, board.T, blocks):
        for line in grid:
            non_empty = line(line != empty_value)
            if not len(non_empty) == len(set(non_empty)):
                return False
    return True

Stats:

Runtime: 172 ms, faster than 5.19% of Python3 online submissions for Valid Sudoku.
Memory Usage: 30.2 MB, less than 11.10% of Python3 online submissions for Valid Sudoku.

valid_sudoku.h

#ifndef LEETCODE_VALID_SUDOKU_H
#define LEETCODE_VALID_SUDOKU_H

#include <string_view>
#include <unordered_set>

bool sudoku_check_update(const size_t &row, const size_t &col, const char &value,
                         const int &block_size,
                         std::unordered_set<std::string_view> &seen);

bool sudoku_check(const std::vector<std::vector<char>> &board,
                  const char &empty_value = '.');

void test1();

#endif //LEETCODE_VALID_SUDOKU_H

valid_sudoku.cpp

#include <iostream>
#include <vector>
#include <string_view>
#include <cmath>
#include <unordered_set>


bool sudoku_check_update(const size_t &row, const size_t &col, const char &value,
                         const int &block_size,
                         std::unordered_set<std::string_view> &seen) {
    std::string_view r, c, b;
    r = "0-" + std::to_string(row) + value;
    c = "1-" + std::to_string(col) + value;
    b = "2-" + std::to_string(row / block_size) + std::to_string(col / block_size) +
        value;
    for (const auto &seen_id: {r, c, b}) {
        if (seen.find(seen_id) != seen.end())
            return false;
        seen.insert(seen_id);
    }
    return true;
}


bool sudoku_check(const std::vector<std::vector<char>> &board,
                  const char &empty_value = '.') {
    std::unordered_set<std::string_view> seen;
    const auto row_size = board.size();
    const int block_size = std::sqrt(row_size);
    for (size_t row = 0; row < row_size; ++row) {
        for (size_t col = 0; col < row_size; ++col) {
            auto value = board(row)(col);
            if (value == empty_value)
                continue;
            if (!sudoku_check_update(row, col, value, block_size, seen))
                return false;
        }
    }
    return true;
}


void test1() {
    std::vector<std::vector<char>> v = {
            {'5', '3', '.', '.', '7', '.', '.', '.', '.'},
            {'6', '.', '.', '1', '9', '5', '.', '.', '.'},
            {'.', '9', '8', '.', '.', '.', '.', '6', '.'},
            {'8', '.', '.', '.', '6', '.', '.', '.', '3'},
            {'4', '.', '.', '8', '.', '3', '.', '.', '1'},
            {'7', '.', '.', '.', '2', '.', '.', '.', '6'},
            {'.', '6', '.', '.', '.', '.', '2', '8', '.'},
            {'.', '.', '.', '4', '1', '9', '.', '.', '5'},
            {'.', '.', '.', '.', '8', '.', '.', '7', '9'}
    };
    std::cout << sudoku_check(v);
}

Stats:

Runtime: 48 ms, faster than 17.98% of C++ online submissions for Valid Sudoku.
Memory Usage: 20.4 MB, less than 22.55% of C++ online submissions for Valid Sudoku.

Excel 2019 data validation list valid formula

I am trying to create a formula for a drop down list based on a conditional format, where only the cells in G column will be shown if in the column before (the F one) in the same row the cell has some predefined value.

When running the formula on a cell and if i press F9 it will the following result

={"Doc";"Doc";"Doc";"rec 3";"Doc";"Doc";"Doc";"Doc";"Doc";"rec 9";"rec 10";"rec 11";"rec 12"}

However when i place such formula in the Data Validation under the option list it will show only the first result.
The Idea is to create such dropdown with the use of a direct approach and not with the use of third cells where i will have the place the result on them.

This is the formula

=OFFSET(F1,IF( ((F2:F14=K4))*ROW(F2:F14) = 0, 0,( ((F2:F14=K4))*ROW(F2:F14))-1),1)

I have try as well placing the INDIRECT formula on it but it gives an error… Not sure what else i can do…

Thanks in advance

linear algebra – Is the reduction of this system of nonlinear equations *really* valid?

I’m looking at this post, over on Stack Overflow.

I’ll summarize here.

We’re given the nonlinear system:

$(A_x – P_x)^2 + (A_y – P_y)^2 = (v(t_a – t_0))^2$ ${1}$

$(A_x – P_x)^2 + (A_y – P_y)^2 = (v(t_a – t_0))^2$ ${2}$

$(A_x – P_x)^2 + (A_y – P_y)^2 = (v(t_a – t_0))^2$ ${3}$

Where $P_x, P_y,$ and $t_0$ are unknown. We’re trying to determine $P_x, P_y$.

The answerer says to, “open the brackets, and subtract ${2}$${1}$, ${3}$${2}$, ${1}$${3}$ to discard squares of unknown terms”. Now, we have the linear system:

$B_x^2-A_x^2 -2*(B_x-A_x)*P_x + B_y^2-A_y^2 -2*(B_y-A_y)*P_y = v^2*(t_b^2-t_a^2 -2*(t_b-t_a)*t_0)$

$C_x^2-B_x^2 -2*(C_x-B_x)*P_x + C_y^2-B_y^2 -2*(C_y-B_y)*P_y = v^2*(t_c^2-t_b^2 -2*(t_c-t_b)*t_0)$

$A_x^2-C_x^2 -2*(A_x-C_x)*P_x + A_y^2-C_y^2 -2*(A_y-C_y)*P_y = v^2*(t_a^2-t_c^2 -2*(t_a-t_c)*t_0)$

…which can be solved easily using Gaussian elimination.


Is this a valid solution? I ask as I’ve seen others attempt to solve this very system using much more complex methods, such as Newton’s method. If so, why would anyone attempt anything more complicated than this (simple Gaussian elimination, e.g.)? Surely something must be missing here?

terminal – gpg: no valid OpenPGP data found. É a resposta quando tento adicionar um repositorio no linux, como resolver?

Estou tentando executar o comando add-apt-repository ppa:linuxuprising/java
Mas estou recebendo a resposta abaixo
gpg: keybox ‘/tmp/tmpn8pp_nua/pubring.gpg’ created
gpg: /tmp/tmpn8pp_nua/trustdb.gpg: trustdb created
gpg: key EA8CACC073C3DB2A: public key “Launchpad PPA for Linux Uprising” imported
gpg: Total number processed: 1
gpg: imported: 1
gpg: no valid OpenPGP data found.

Se alguem puder me ajudar agradeço muito mesmo de verdade.

encryption – Difference between access control systems that can/can’t be compromised without valid credentials?

Take the following examples:

  1. When I run sshd, it can in theory grant access to anything that the process itself has access to, regardless of provided credentials. For example, I could in theory modify a single if statement in the sshd source to grant access to my home directory to anyone.

  2. On the other hand, if I encrypt my home directory and it can only be decrypted with my login password, sshd (and a local root session, for that matter) could only access that information with either my password or some extreme coincidence of poor and malicious programming.

In the first case, my home directory is compromised if a single predicate misbehaves in sshd. In the second case, a compromise, accidental or otherwise, is extremely unlikely unless my password is compromised or the encryption algorithm is flawed.

We could also include analogous physical scenarios, and (in some sense) “security through obscurity”, e.g., ssh couldn’t connect to my machine without knowing its IP address.


Does this distinction occur somewhere in the discourse of access control? For example, if I wanted to refer to a system where an unreliable agent can easily compromise access, vs. one where that is extremely unlikely. (It seems like this is a superset of the DAC vs. MAC distinction.)

logic – Is my UML Use Case Diagram valid?

I’m preparing an UML use case diagram for my following school project:

The main goal of the project is to design a software that eases the process of installing an
operating system in today's systems. Normally the users must download the distribution
that they think is most suitable for them, burn the downloaded image of the distribution (ISO)
to a removable media (USB), boot the removable media, and then start the installation process.
Since all these stages have many sub-steps, installing an operating system is not something
that most people can do easily.

It’s an abstract subject and it’s not expected to be something completely realistic whatsoever. So here’s the Use Case Diagram that I was working on:

use case diagram

Visual Paradigm project

My question is: Is this usage correct? Do I have to fix/replace/add something?

role assignment – Add or remove Folder RoleAssignments not valid error

Having trouble with adding or removing RoleAssignments on Sharepoint document folders using REST API through FLOW.

Process is to copy a Template folder with subfolders. Of which, 2 subfolders need unique permissions to prevent unwanted user access.

I believe BreakRoleInheritance is being broken properly prior
Sent POST via Send HTTP request via SharePoint
”’_api/web/GetFolderByServerRelativeUrl(‘Shared Documents/SHOW FOLDERS/2017 Budgets/01 January/SHOW20′)/ListItemAllFields/breakroleinheritance(copyRoleAssignments=true,clearSubscopes=true)”’

Sample command sending DELETE via HTTP to remove a SP Group with ID of (6) from folder
”’_api/web/GetFolderByServerRelativeUrl(‘Shared Documents/SHOW FOLDERS/2017 Budgets/01 January/SHOW20′)/ListItemAllFields/roleassignments/getbyprincipalid(6)”’

Error output
”'{
“status”: 400,
“message”: “The expression “web/GetFolderByServerRelativeUrl(‘Shared Documents/SHOW FOLDERS/2017 Budgets/01 January/SHOW20′)/ListItemAllFields/roleassignments/getbyprincipalid(6)” is not valid.rnclientRequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxrnserviceRequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,
“source”: “https://xxxxxxxxx.sharepoint.com/sites/FILETRANSFER/_api/web/GetFolderByServerRelativeUrl(%E2%80%98Shared%20Documents/SHOW%20FOLDERS/2017%20Budgets/01%20January/SHOW20′)/ListItemAllFields/roleassignments/getbyprincipalid(6)”,
“errors”: (
“-1”,
“Microsoft.SharePoint.Client.InvalidClientQueryException”
)
}”’